Files
Haran Rajkumar 9d0a5a8615 test(samples): add replay tests for the interactions_api sample
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
2026-06-30 15:31:21 -07:00

38 lines
1.0 KiB
JSON

{
"events": [
{
"author": "user",
"content": {
"parts": [
{
"text": "Hello! What can you help me with?"
}
],
"role": "user"
},
"id": "e-1",
"invocationId": "i-1",
"nodeInfo": {
"path": ""
}
},
{
"author": "interactions_test_agent",
"content": {
"parts": [
{
"text": "Hello! I am \"interactions_test_agent,\" an agent designed for testing the Interactions API integration.\n\nI can help you with two main tasks:\n1. **Searching the web:** If you have questions that require up-to-date information, I can search the web for you.\n2. **Checking the weather:** I can provide the current weather for a specific city.\n\nHow can I assist you today?"
}
],
"role": "model"
},
"finishReason": "STOP",
"id": "e-2",
"invocationId": "i-1",
"nodeInfo": {
"path": "interactions_test_agent@1"
}
}
]
}