Skip to content

Gracefully handling tool failures #2671

@geodavic

Description

@geodavic

I noticed that if a tool fails more than the configured max_retries, the run fails (raises an exception).

How can I gracefully allow these failures? Say a tool should fail and the agent needs to find a different approach. The main use case I'm dealing with is tools that make API calls that result in a 400-type error and raise it. I don't want the run to end just because a resource wasn't found. How can I configure this?

My first solution was to just wrap the tool in a try/except clause, and return the error string if an exception gets raised. But that feels like the wrong approach (especially since I'm dynamically generating my tools, and monkeypatching the return types to be Union[str, ...] everywhere would be messy)

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions