Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions tests/unittests/test_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,36 @@ async def test_run_config_custom_metadata_propagates_to_events():
assert user_event.custom_metadata == {"request_id": "req-1"}


@pytest.mark.asyncio
async def test_run_async_assertions_use_refetched_session_snapshot():
session_service = InMemorySessionService()
runner = Runner(
app_name=TEST_APP_ID,
agent=MockAgent("snapshot_agent"),
session_service=session_service,
artifact_service=InMemoryArtifactService(),
)
created_session = await session_service.create_session(
app_name=TEST_APP_ID, user_id=TEST_USER_ID, session_id=TEST_SESSION_ID
)

async for _ in runner.run_async(
user_id=TEST_USER_ID,
session_id=TEST_SESSION_ID,
new_message=types.Content(role="user", parts=[types.Part(text="hi")]),
):
pass

# InMemorySessionService returns copies; the original handle is stale after run_async.
assert len(created_session.events) == 0

refreshed_session = await session_service.get_session(
app_name=TEST_APP_ID, user_id=TEST_USER_ID, session_id=TEST_SESSION_ID
)
assert refreshed_session is not None
assert len(refreshed_session.events) > 0


class TestRunnerWithPlugins:
"""Tests for Runner with plugins."""

Expand Down