fix(backends): remember the session id from the first frame so a cut turn stays resumable
This commit is contained in:
@@ -96,11 +96,13 @@ class ScriptedClient:
|
||||
async def receive_response(self):
|
||||
prompt = self.prompts[-1]
|
||||
yield StreamEvent(
|
||||
uuid="u", session_id="s", event={"type": "message_start", "message": {}}
|
||||
uuid="u",
|
||||
session_id=self.session_id,
|
||||
event={"type": "message_start", "message": {}},
|
||||
)
|
||||
yield StreamEvent(
|
||||
uuid="u",
|
||||
session_id="s",
|
||||
session_id=self.session_id,
|
||||
event={
|
||||
"type": "content_block_start",
|
||||
"index": 0,
|
||||
@@ -109,7 +111,7 @@ class ScriptedClient:
|
||||
)
|
||||
yield StreamEvent(
|
||||
uuid="u",
|
||||
session_id="s",
|
||||
session_id=self.session_id,
|
||||
event={
|
||||
"type": "content_block_delta",
|
||||
"index": 0,
|
||||
@@ -117,7 +119,9 @@ class ScriptedClient:
|
||||
},
|
||||
)
|
||||
yield StreamEvent(
|
||||
uuid="u", session_id="s", event={"type": "content_block_stop", "index": 0}
|
||||
uuid="u",
|
||||
session_id=self.session_id,
|
||||
event={"type": "content_block_stop", "index": 0},
|
||||
)
|
||||
yield AssistantMessage(content=[TextBlock(text=f"ok:{prompt}")], model="m")
|
||||
hold = ScriptedClient.hold
|
||||
@@ -505,6 +509,7 @@ async def test_graceful_stop_keeps_running_turn_for_recover(world: World) -> Non
|
||||
await world.conversations.stop()
|
||||
row = await world.conversations.get(conv.external_id)
|
||||
assert row.running_turn is not None
|
||||
assert row.session_id == ScriptedClient.instances[0].session_id
|
||||
cut = await world.conversations.recover()
|
||||
assert [c.external_id for c in cut] == [conv.external_id]
|
||||
assert (await world.conversations.get(conv.external_id)).running_turn is None
|
||||
|
||||
Reference in New Issue
Block a user