Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sometimes, tool calls result in errors. These can be minor ones, e.g. the mouse cannot be moved to the requested position as it is off-screen, or critical ones, e.g. the controller is offline.
Currently, the agent tries to recover from all errors on its own, however, some errors are unfixable. This leads to the agent consuming a lot of tokens while looping to solve an unsolvable problem.
In this PR, I added explicit handling of tool errors in the control loop of the conversation, so that we can stop the conversation if an error occurred that is marked as unfixable.
The change works as follows:
error_type: ERROR_TYPE. This is set aserror_type = type(e).__name__if an error occurred.tool_result_messagein the conversation as optional parameter (only exists if there were tool calls) to the_handle_continue_conversationmethod. In this method, we check if an unfixable error occurred by checking if 1) the parameter is not None, 2) if it has a statusis_error=True, 3) if it’sERROR_TYPEis listed in “unfixable_errors”. If all these are True, we return a value ofFalse, i.e. the conversation will not be continued.