Skip to content

refactor(llm): unified ToolError contract for tool arg validation#5807

Open
longcw wants to merge 1 commit into
mainfrom
longc/tool-error-contract
Open

refactor(llm): unified ToolError contract for tool arg validation#5807
longcw wants to merge 1 commit into
mainfrom
longc/tool-error-contract

Conversation

@longcw
Copy link
Copy Markdown
Contributor

@longcw longcw commented May 22, 2026

Summary

Argument validation now raises ToolError directly inside prepare_function_arguments, so the message the LLM sees is owned in one place.

  • prepare_function_arguments wraps ValidationError / ValueError / TypeError as ToolError(\"Error parsing arguments for ...\").
  • execute_function_call drops its dedicated (ValidationError, ValueError) branch and no longer logs a traceback for ToolError — it's intentional signal to the LLM, not a bug.
  • _execute_tools_task moves argument prep into a _execute(ctx) closure called inside the per-tool try block, so a ToolError from arg validation 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.

- 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.
@chenghao-mou chenghao-mou requested a review from a team May 22, 2026 07:32
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant