| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…g Conversion - Pass include_extras=True to get_type_hints in the JSON-schema declaration builder so Annotated[T, Field(...)] descriptions and constraints reach the generated schema, matching the legacy builder - Unwrap Annotated in FunctionTool._preprocess_args (top-level and per union member) so dict-to-model conversion works when get_type_hints falls back to the raw annotation - Add tests covering both builders and the resolved and fallback arg paths
The rebase pulled in an upstream dead `import pytest` in test_function_tool_declarations.py; F401 flags it once this PR touches the file.
| Back | FazBrowse Home | New Git URL |
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
When the JSON_SCHEMA_FOR_FUNC_DECL feature is enabled, typing.Annotated metadata was silently dropped in two places:
Declaration builder. _function_tool_declarations._get_function_fields called get_type_hints() without include_extras=True, so Annotated[T, Field(description=..., ge=1)] was unwrapped to a bare T before Pydantic's create_model saw it. Every description and constraint an author attached via Annotated was missing from the schema shown to the model. The legacy builder never had this problem, so this was a regression between the two paths.
Argument conversion. FunctionTool._preprocess_args resolves parameter types with get_type_hints(), which strips Annotated for free. But when get_type_hints() cannot resolve a signature (an unresolvable forward reference anywhere in it e.g. a TYPE_CHECKING-only import or a recursive type alias), it raises and the code falls back to the raw param.annotation, which is still Annotated-wrapped. None of the conversion branches recognised the wrapper, so JSON dicts from the model reached the function body unconverted (which later led to AttributeError's as described in the original issue on "member access" of the model, which in fact was passed as a raw dict).
Solution:
Testing Plan
Unit Tests:
Added 16 tests across three existing files:
Each fix was verified by stashing it and confirming the corresponding tests that check for correct behavior fail before, and un-stashing fixes.
Manual End-to-End (E2E) Tests:
r.e issue #6877: I went in with the debugger and checked that the FunctionDeclarations in basic_llm_flow.py now contain parameter/outputss descriptions and constraints where now there.
r.e. issue #6878: I observed the absence of the exception presented in the issue, when using a tool with a recursive type, and access a member of a Pydantic model.
Checklist
There are none here for context.
Additional context
None.