refactor(llm): unified ToolError contract for tool arg validation#5807
Open
longcw wants to merge 1 commit into
Open
refactor(llm): unified ToolError contract for tool arg validation#5807longcw wants to merge 1 commit into
longcw wants to merge 1 commit into
Conversation
- prepare_function_arguments wraps ValidationError/ValueError/TypeError as
ToolError("Error parsing arguments for ..."), so the message the LLM sees
is owned in one place.
- execute_function_call drops its dedicated validation branch and no longer
logs a traceback for ToolError — it's intentional signal to the LLM.
- _execute_tools_task moves argument prep into a _execute(ctx) closure called
inside the per-tool try block, so the new ToolError is routed via
_tool_completed the same way a ToolError raised by the tool body is.
- ToolProxyToolset._handle_call drops its own try/except wrapper.
Extracted from #5711.
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
Argument validation now raises
ToolErrordirectly insideprepare_function_arguments, so the message the LLM sees is owned in one place.prepare_function_argumentswrapsValidationError/ValueError/TypeErrorasToolError(\"Error parsing arguments for ...\").execute_function_calldrops its dedicated(ValidationError, ValueError)branch and no longer logs a traceback forToolError— it's intentional signal to the LLM, not a bug._execute_tools_taskmoves argument prep into a_execute(ctx)closure called inside the per-tool try block, so aToolErrorfrom arg validation is routed via_tool_completedthe same way aToolErrorraised by the tool body is.ToolProxyToolset._handle_calldrops its own try/except wrapper.Extracted from #5711.