You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Annotated State parameters break tool creation #13166
create_tool_from_function() and ComponentTool fail to build a tool when an injected agent State parameter is wrapped in typing.Annotated. Plain State and State | None parameters are intentionally omitted from the model's JSON schema, but the same type with annotation metadata is sent to Pydantic, which cannot generate a State schema.
Error message
SchemaGenerationError: Failed to create JSON schema for function 'inspect_state', caused by Pydantic being unable to generate a schema for State. ComponentTool raises the analogous component-run schema error.
Expected behavior
Exclude an Annotated[State, ...] parameter from the generated schema and inject the live State during agent tool execution, consistently with unwrapped State. Optional annotation wrappers should work too. State-dependent calls must retain their existing dependency ordering.
This fails during public tool creation without model credentials or network requests. Replacing the annotation with plain State succeeds and yields a schema containing only query.
Additional context
A prepared fix branch unwraps annotation and optional wrappers in the existing runtime-type helper and includes a release note. Sixteen regression cases fail on current main and pass with the fix. The affected schema, function-tool, component-tool, and tool-calling modules pass 158 tests, with seven live-API tests skipped. Targeted mypy and applicable repository pre-commit checks pass. The full suite and live integrations were not run; tests used a focused Hatch environment on Python 3.12.
This concerns State recognition and injection, separately from callback schema filtering in #13137/#13138. I already have #13138 open, so I am keeping the fix on a branch until that PR is accepted or closed, following the one-open-community-PR rule. Prepared and validated with Codex.
Activity