feat: add tool_call_error_function to AssistantAgent for custom error handling#7387
Open
majiayu000 wants to merge 1 commit intomicrosoft:mainfrom
Open
feat: add tool_call_error_function to AssistantAgent for custom error handling#7387majiayu000 wants to merge 1 commit intomicrosoft:mainfrom
majiayu000 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
… handling Allow tool call exceptions to be handled by a user-provided callback instead of being silently stringified. The callback receives the exception and FunctionCall, and returns either a string (handled error) or None (re-raise as fatal). - Add raise_on_error parameter to StaticWorkbench/StaticStreamWorkbench - Thread tool_call_error_function through AssistantAgent pipeline - Wrap asyncio.gather in try/except to ensure stream sentinel on error - Add tests for all error handling paths Fixes microsoft#5340 Signed-off-by: majiayu000 <1835304752@qq.com>
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.
Summary
tool_call_error_functionparameter toAssistantAgentthat allows callers to control how tool execution errors are handledstr, it is used as the error content (recoverable error)None, the original exception is re-raised (fatal error)Fixes #5340
Changes
StaticWorkbench/StaticStreamWorkbench: addedraise_on_errorparameter to control exception propagationAssistantAgent.__init__: addedtool_call_error_functionparameterAssistantAgent._execute_tool_call: wrapped workbench call in try/except, delegates to error functionAssistantAgent._execute_tool_calls: wrappedasyncio.gatherin try/except to ensure stream sentinel (None) is sent on error, preventing consumer loop hangsTest plan
pytest tests/test_assistant_agent.py::TestToolCallErrorFunction— 3/3 passpyrighttype checking — 0 errors on both modified source files