Skip to content

Commit dea8050

Browse files
committed
Update test to account for fact that text output with early end_strategy stops later tools from being called
1 parent db82d00 commit dea8050

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

tests/models/test_gemini.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,12 +965,47 @@ async def test_stream_text_heterogeneous(get_gemini_client: GetGeminiClient):
965965

966966
@agent.tool_plain()
967967
def get_location(loc_name: str) -> str:
968-
return f'Location for {loc_name}'
968+
return f'Location for {loc_name}' # pragma: no cover
969969

970970
async with agent.run_stream('Hello') as result:
971971
data = await result.get_output()
972972

973973
assert data == 'Hello foo'
974+
assert result.all_messages() == snapshot(
975+
[
976+
ModelRequest(
977+
parts=[
978+
UserPromptPart(
979+
content='Hello',
980+
timestamp=IsDatetime(),
981+
)
982+
]
983+
),
984+
ModelResponse(
985+
parts=[
986+
TextPart(content='Hello foo'),
987+
ToolCallPart(
988+
tool_name='get_location',
989+
args={'loc_name': 'San Fransisco'},
990+
tool_call_id=IsStr(),
991+
),
992+
],
993+
usage=Usage(request_tokens=1, response_tokens=2, total_tokens=3, details={}),
994+
model_name='gemini-1.5-flash',
995+
timestamp=IsDatetime(),
996+
),
997+
ModelRequest(
998+
parts=[
999+
ToolReturnPart(
1000+
tool_name='get_location',
1001+
content='Tool not executed - a final result was already processed.',
1002+
tool_call_id=IsStr(),
1003+
timestamp=IsDatetime(),
1004+
)
1005+
]
1006+
),
1007+
]
1008+
)
9741009

9751010

9761011
async def test_empty_text_ignored():

0 commit comments

Comments
 (0)