core[patch]: Correct type casting of annotations in _infer_arg_descriptions (#31181)

- **Description:** 
- In _infer_arg_descriptions, the annotations dictionary contains string
representations of types instead of actual typing objects. This causes
_is_annotated_type to fail, preventing the correct description from
being generated.
- This is a simple fix using the get_type_hints method, which resolves
the annotations properly and is supported across all Python versions.

  - **Issue:** #31051

---------

Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
This commit is contained in:
Mohammad Mohtashim
2025-06-05 20:58:36 +05:00
committed by GitHub
parent dea43436ea
commit ae3551c96b
2 changed files with 24 additions and 6 deletions

View File

@@ -2711,3 +2711,24 @@ def test_tool_invoke_does_not_mutate_inputs() -> None:
"id": "call_0_82c17db8-95df-452f-a4c2-03f809022134",
"type": "tool_call",
}
def test_tool_args_schema_with_annotated_type() -> None:
@tool
def test_tool(
query_fragments: Annotated[
list[str],
"A list of query fragments",
],
) -> list[str]:
"""Search the Internet and retrieve relevant result items."""
return []
assert test_tool.args == {
"query_fragments": {
"description": "A list of query fragments",
"items": {"type": "string"},
"title": "Query Fragments",
"type": "array",
}
}