Skip to content

Commit 80dd6e3

Browse files
committed
Add test outline
1 parent 0ee01f1 commit 80dd6e3

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

tests/test_agent.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6125,3 +6125,65 @@ def llm(messages: list[ModelMessage], _info: AgentInfo) -> ModelResponse:
61256125
]
61266126
)
61276127
assert run.all_messages_json().startswith(b'[{"parts":[{"content":"Hello",')
6128+
6129+
6130+
async def test_text_output_json_schema():
6131+
def llm(messages: list[ModelMessage], info: AgentInfo) -> ModelResponse:
6132+
return ModelResponse(parts=[TextPart('')])
6133+
6134+
agent = Agent(FunctionModel(llm))
6135+
output_schema = {'type': 'string'}
6136+
assert agent.output_json_schema == output_schema
6137+
6138+
6139+
async def test_tool_output_json_schema():
6140+
def llm(messages: list[ModelMessage], info: AgentInfo) -> ModelResponse:
6141+
return ModelResponse(parts=[TextPart('')])
6142+
6143+
agent = Agent(FunctionModel(llm), output_type=[ToolOutput(bool)])
6144+
assert agent.output_json_schema
6145+
6146+
agent = Agent(FunctionModel(llm), output_type=[ToolOutput(bool), ToolOutput(bool)])
6147+
assert agent.output_json_schema
6148+
6149+
6150+
async def test_native_output_json_schema():
6151+
def llm(messages: list[ModelMessage], info: AgentInfo) -> ModelResponse:
6152+
return ModelResponse(parts=[TextPart('')])
6153+
6154+
agent = Agent(
6155+
FunctionModel(llm),
6156+
output_type=NativeOutput([bool], name='native_output_name', description='native_output_description')
6157+
)
6158+
assert agent.output_json_schema
6159+
6160+
6161+
async def test_prompted_output_json_schema():
6162+
def llm(messages: list[ModelMessage], info: AgentInfo) -> ModelResponse:
6163+
return ModelResponse(parts=[TextPart('')])
6164+
6165+
agent = Agent(
6166+
FunctionModel(llm),
6167+
output_type=PromptedOutput([bool], name='prompted_output_name', description='prompted_output_description')
6168+
)
6169+
assert agent.output_json_schema
6170+
6171+
6172+
async def test_custom_output_json_schema():
6173+
def llm(messages: list[ModelMessage], info: AgentInfo) -> ModelResponse:
6174+
return ModelResponse(parts=[TextPart('')])
6175+
6176+
HumanDict = StructuredDict(
6177+
{
6178+
'type': 'object',
6179+
'properties': {
6180+
'name': {'type': 'string'},
6181+
'age': {'type': 'integer'}
6182+
},
6183+
'required': ['name', 'age']
6184+
},
6185+
name='Human',
6186+
description='A human with a name and age',
6187+
)
6188+
agent = Agent(FunctionModel(llm), output_type=HumanDict)
6189+
assert agent.output_json_schema

0 commit comments

Comments
 (0)