Skip to content

fix(tools): include pydantic field errors in beta_tool invalid-args message - #2041

Open
mangeshraut712 wants to merge 1 commit into
anthropics:mainfrom
mangeshraut712:tip/beta-tool-validation-error-detail
Open

mangeshraut712 wants to merge 1 commit into
anthropics:mainfrom
mangeshraut712:tip/beta-tool-validation-error-detail

Conversation

@mangeshraut712

Copy link
Copy Markdown

Summary

When beta_tool / beta_async_tool reject bad arguments, the model only saw Invalid arguments for function X with the pydantic field errors left on __cause__. Append a short loc: message summary (values not echoed) so the model can correct the next call.

Fixes #2033

Test plan

  • pytest tests/lib/tools/test_functions.py -k "validation_error_includes or function_call_with_invalid"

…essage

Validation failures previously raised a bare "Invalid arguments for
function X", so the model could not tell which argument was wrong.
Append a short loc: message summary (values not echoed).

Fixes anthropics#2033
@mangeshraut712
mangeshraut712 requested a review from a team as a code owner October 27, 2026 08:09

This branch has not been deployed

No deployments
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.

beta_tool validation errors reach the model as "Invalid arguments for function X" with no detail

1 participant