CubeLoop — a Pythonic, async-native agent harness core designed for high performance, readability, and production-grade persistence.
Python agent-frameworkagent-harnessagent-runtimeagentic-aiai-agentsai-frameworkanthropicharnessharness-engineeringharness-frameworklanggraphlanggraph-alternativellmmcpopenaipi-agentpi-agent-corepythonpython-agent
plan: address plan-review R12 (2 HIGH)
xf gong57a4cc97c8fa
diff --git a/dev/plans/2026-06-05-conversation-fork.md b/dev/plans/2026-06-05-conversation-fork.mdindex 2d29400..2f8b2b9 100644--- a/dev/plans/2026-06-05-conversation-fork.md+++ b/dev/plans/2026-06-05-conversation-fork.md@@ -3243,7 +3243,6 @@ Create `tests/agent/test_agent_completion.py`:```pythonimport asyncio-import contextlibimport pytest@@ -4094,12 +4093,51 @@ async def respond(# Spec §3.7: leave active_run_id SET on raise.raiseelse:- outcome = self._state.last_outcome or "abandoned"- await self._dispatch_outcome(outcome, recovered_run_id)- # Clear on successful resume completion.+ # Legacy guard: pending rows written by pre-spec code+ # may carry run_id=None. Skip dispatch entirely — the+ # caller didn't opt into run tracking for this run.+ if recovered_run_id is not None:+ outcome = self._state.last_outcome or "abandoned"+ await self._dispatch_outcome(outcome, recovered_run_id)+ # Clear on successful resume completion (legacy or not).self._state.active_run_id = None```+Add a regression test mirroring the legacy case:++```python+async def test_respond_resume_with_legacy_pending_does_not_crash():+ """A pre-spec pending row was written without run_id. respond()+ must resume cleanly: no claim, no mark, no crash."""+ cp = MemoryCheckpointer()+ p = _pause_then_finish_provider()+ a, task = await _drive_pause(cp, lambda: p.model("faux-model"))+ await a.detach()+ await task+ # Forge legacy state: clear the pending row's run_id (simulating+ # the pre-spec on-disk shape).+ pending_req = (await cp.load_pending("t"))[0]+ await cp.save_pending_request("t", pending_req, run_id=None)++ ch2 = CheckpointedChannel(checkpointer=cp, thread_id="t", run_id=None)+ tool2 = ask_user_tool(ch2)+ a2 = Agent(+ model=p.model("faux-model"),+ tools=[tool2],+ checkpointer=cp,+ thread_id="t",+ channel=ch2,+ )+ pending = await cp.load_pending("t")+ qid = pending[0].question_id+ # Must not raise.+ await a2.respond(question_id=qid, answer="yes")+ # No marker (run_id was None on resume) — but the messages are+ # persisted and the thread is in a coherent state.+ assert "R1" not in cp._runs.get("t", {})+```+**Do not call `claim_run` here.** All subsequent append calls use`self._state.active_run_id` (the same chokepoint as prompt — seeTask 23). At terminal clean exit, `_dispatch_outcome` (from Task 26)