The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(onboarding): a scripted prelude's tool call id is unique per chat
alt-glitch7e0d89c4fc92
diff --git a/agent/turn_scripted_prelude.py b/agent/turn_scripted_prelude.pyindex 8f031355d7e..1eeb6580f32 100644--- a/agent/turn_scripted_prelude.py+++ b/agent/turn_scripted_prelude.py@@ -24,6 +24,12 @@ from agent.turn_tool_round import run_tool_roundPrelude = Generator[tuple[str, str, dict], Optional[str], None]+def prelude_call_id(session_id: str, name: str, args: dict, index: int) -> str:+ """Seeded by the session, the call and its place in history: no two chats share an id (a rerun plays+ the same card at the same place), and it stays byte-stable on replay."""+ return deterministic_call_id(name, f"{session_id}:{json.dumps(args, sort_keys=True)}", index)++def run_scripted_prelude(agent: Any, s: Any, prelude: Prelude) -> Any:"""Play ``prelude`` into the loop state ``s``; returns the last tool round's verdict, or None whenno step ran. The caller ends the turn on ``return`` and skips the model on ``break``."""@@ -38,9 +44,7 @@ def run_scripted_prelude(agent: Any, s: Any, prelude: Prelude) -> Any:s.finish_reason = "tool_calls"s.assistant_message = NormalizedResponse(content=content, finish_reason="tool_calls",- # Seeded by the card and its place in history: unique within the session, byte-stable on replay.- tool_calls=[build_tool_call(deterministic_call_id(name, json.dumps(args, sort_keys=True), len(s.messages)),- name, args)])+ tool_calls=[build_tool_call(prelude_call_id(agent.session_id, name, args, len(s.messages)), name, args)])verdict = _run_phase(run_tool_round, agent, s)if verdict.action != "continue":breakdiff --git a/tests/agent/test_turn_scripted_prelude.py b/tests/agent/test_turn_scripted_prelude.pynew file mode 100644index 00000000000..5a2b502c525--- /dev/null+++ b/tests/agent/test_turn_scripted_prelude.py@@ -0,0 +1,11 @@+"""A scripted prelude's tool call id is unique per chat: a rerun of onboarding plays the same name card at the+same place in a new chat, and the desktop keys tool rows by that id."""++from agent.turn_scripted_prelude import prelude_call_id+++def test_the_same_card_at_the_same_place_gets_a_different_id_in_another_chat():+ first = prelude_call_id("chat-1", "setup_beat", {"beat": "name"}, 1)++ assert first == prelude_call_id("chat-1", "setup_beat", {"beat": "name"}, 1)+ assert first != prelude_call_id("chat-2", "setup_beat", {"beat": "name"}, 1)