Skip to content

Commit 1fd144b

Browse files
committed
Fix function output
1 parent d78106b commit 1fd144b

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

pydantic_ai_slim/pydantic_ai/agent/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
from .. import (
2121
_agent_graph,
22-
_function_schema,
2322
_output,
2423
_system_prompt,
2524
_utils,
@@ -981,9 +980,7 @@ def output_json_schema(self, output_type: OutputSpec[OutputDataT | RunOutputData
981980
json_schemas: list[JsonSchema] = []
982981
for _ in output_type:
983982
if inspect.isfunction(_) or inspect.ismethod(_):
984-
function_schema = _function_schema.function_schema(_, GenerateToolJsonSchema)
985-
json_schema = function_schema.json_schema
986-
json_schema['description'] = function_schema.description
983+
json_schema = TypeAdapter(inspect.signature(_).return_annotation).json_schema(mode='serialization')
987984
elif isinstance(_, _output.TextOutput):
988985
json_schema = TypeAdapter(str).json_schema(mode='serialization')
989986
else:

tests/test_agent_output_schemas.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,7 @@ def func(x: int) -> int:
4141
return x
4242

4343
agent = Agent('test', output_type=[func])
44-
assert agent.output_json_schema() == snapshot(
45-
{
46-
'additionalProperties': False,
47-
'properties': {'x': {'type': 'integer'}},
48-
'required': ['x'],
49-
'type': 'object',
50-
'description': None,
51-
}
52-
)
44+
assert agent.output_json_schema() == snapshot({'type': 'integer'})
5345

5446

5547
async def test_auto_output_json_schema():

0 commit comments

Comments
 (0)