9d0a5a8615
Add replay test fixtures covering the documented flows of the contributing/samples/models/interactions_api sample (basic text, Google Search grounding, multi-turn stateful recall, and a custom function tool), so the sample is exercised by tests/unittests/test_samples.py. Also fix the shared sample test harness (cli/agent_test_runner.py) to support the Interactions API: - Exclude the volatile interaction_id (a server-issued token) and turn_complete fields from fixture comparison and from rebuilt fixtures, matching how other non-reproducible fields (timestamps, usage metadata, etc.) are already handled. The Interactions API stamps these onto every model response and the replay MockModel cannot reproduce them. - Drive all turns of a fixture rebuild on a single persistent event loop. The sync Runner.run() uses asyncio.run() per call, which closes the loop the model's cached async api_client is bound to, so subsequent turns fail with "Event loop is closed" and corrupt multi-turn fixtures. Reusing one loop keeps the cached client valid across the conversation. Co-authored-by: Haran Rajkumar <haranrk@google.com> PiperOrigin-RevId: 940691339
87 lines
1.8 KiB
JSON
87 lines
1.8 KiB
JSON
{
|
|
"events": [
|
|
{
|
|
"author": "user",
|
|
"content": {
|
|
"parts": [
|
|
{
|
|
"text": "What's the weather like in Tokyo?"
|
|
}
|
|
],
|
|
"role": "user"
|
|
},
|
|
"id": "e-1",
|
|
"invocationId": "i-1",
|
|
"nodeInfo": {
|
|
"path": ""
|
|
}
|
|
},
|
|
{
|
|
"author": "interactions_test_agent",
|
|
"content": {
|
|
"parts": [
|
|
{
|
|
"functionCall": {
|
|
"args": {
|
|
"city": "Tokyo"
|
|
},
|
|
"id": "fc-1",
|
|
"name": "get_current_weather"
|
|
}
|
|
}
|
|
],
|
|
"role": "model"
|
|
},
|
|
"finishReason": "STOP",
|
|
"id": "e-2",
|
|
"invocationId": "i-1",
|
|
"longRunningToolIds": [],
|
|
"nodeInfo": {
|
|
"path": "interactions_test_agent@1"
|
|
}
|
|
},
|
|
{
|
|
"author": "interactions_test_agent",
|
|
"content": {
|
|
"parts": [
|
|
{
|
|
"functionResponse": {
|
|
"id": "fc-1",
|
|
"name": "get_current_weather",
|
|
"response": {
|
|
"city": "Tokyo",
|
|
"condition": "Partly Cloudy",
|
|
"humidity": 60,
|
|
"temperature_f": 68
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"role": "user"
|
|
},
|
|
"id": "e-3",
|
|
"invocationId": "i-1",
|
|
"nodeInfo": {
|
|
"path": "interactions_test_agent@1"
|
|
}
|
|
},
|
|
{
|
|
"author": "interactions_test_agent",
|
|
"content": {
|
|
"parts": [
|
|
{
|
|
"text": "I have retrieved the weather information for Tokyo. It is currently 68\u00b0F and partly cloudy with 60% humidity."
|
|
}
|
|
],
|
|
"role": "model"
|
|
},
|
|
"finishReason": "STOP",
|
|
"id": "e-4",
|
|
"invocationId": "i-1",
|
|
"nodeInfo": {
|
|
"path": "interactions_test_agent@1"
|
|
}
|
|
}
|
|
]
|
|
}
|