From f1172719b4e13d3df11fb5d44a7ee11075e00d2f Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Fri, 11 Sep 2026 17:38:14 +0200 Subject: [PATCH] Make Python persisted-session RPC test replay deterministic Await the replayed user turn before persisting and inspecting session metadata, and add the missing response snapshot. Assert completion instead of racing an unrecorded inference against session detachment. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- python/e2e/test_rpc_server_e2e.py | 12 +++++++----- ...ist_find_and_inspect_persisted_session_state.yaml | 10 ++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 test/snapshots/rpc_server/should_list_find_and_inspect_persisted_session_state.yaml diff --git a/python/e2e/test_rpc_server_e2e.py b/python/e2e/test_rpc_server_e2e.py index 83dc4a01e2..557a533a72 100644 --- a/python/e2e/test_rpc_server_e2e.py +++ b/python/e2e/test_rpc_server_e2e.py @@ -311,17 +311,19 @@ async def test_should_list_find_and_inspect_persisted_session_state( on_permission_request=PermissionHandler.approve_all, ) - await session.send( - "Record a turn for sessions.list discriminator coverage", mode="enqueue" + # Persistence requires a user message. Finish its replayed turn before + # inspecting state or detaching, rather than racing an active inference. + message = await session.send_and_wait( + "Record a turn for sessions.list discriminator coverage" ) + assert message is not None + assert message.data.content == "Recorded." listed = None async def session_is_listed() -> bool: nonlocal listed - # Re-save on every attempt: on slower runners the enqueued turn is not - # necessarily recorded yet when the first save runs, so a single save - # followed by a fixed sleep races the CLI's own persistence. + # Re-save until the runtime's persisted metadata becomes visible. save = await client.rpc.sessions.save(SessionsSaveRequest(session_id=session_id)) assert save is not None listed = await client.rpc.sessions.list( diff --git a/test/snapshots/rpc_server/should_list_find_and_inspect_persisted_session_state.yaml b/test/snapshots/rpc_server/should_list_find_and_inspect_persisted_session_state.yaml new file mode 100644 index 0000000000..bc2ea31ac7 --- /dev/null +++ b/test/snapshots/rpc_server/should_list_find_and_inspect_persisted_session_state.yaml @@ -0,0 +1,10 @@ +models: + - claude-sonnet-5 +conversations: + - messages: + - role: system + content: ${system} + - role: user + content: Record a turn for sessions.list discriminator coverage + - role: assistant + content: Recorded.