You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[pi] plannotator_submit_plan can review a stale plan when batched with a write/edit (parallel tool execution race) #1622
In the pi extension, plannotator_submit_plan sometimes opens the review UI with an outdated version of the plan file. This happens most often after a deny: the agent edits the plan and resubmits in the same assistant message, and the browser shows the previous version.
Cause
pi runs the tool calls of one assistant message in parallel by default. See pi-agent-coreagent-loop.js → executeToolCalls. It only runs them sequentially when toolExecution === "sequential" or when some tool in the batch declares executionMode: "sequential".
When the agent sends edit/write on the plan file and plannotator_submit_plan in one message:
pi's edit/write tools write asynchronously through withFileMutationQueue(absolutePath, ...).
plannotator_submit_plan reads the file synchronously (statSync + readFileSync, apps/pi-extension/index.ts in execute) as soon as it starts. It doesn't take part in the file-mutation queue.
The edit's closure yields on its first I/O await, the submit closure then starts, and readFileSync returns the pre-edit content. That stale text goes to openPlanReviewBrowser → saveToHistory, so history also records the wrong version.
Providers that often batch tool calls make this more likely. I hit it with pi-claude-bridge (Claude Code via the Agent SDK), where Claude routinely sends "edit plan" and "submit plan" together.
Fix
Declare the submit tool sequential so pi serializes any batch that contains it:
The planning-mode write gate only intercepts pi's write/edit. Plans written through other file tools (for example IDE MCP tools that edit the editor buffer) can also be stale on disk when submit reads them. That's probably out of scope here; the ordering race above is the main bug.
Thanks @bugs-wkettlitz, great diagnosis. Your fix was right: #1623 marks plannotator_submit_plan as executionMode: "sequential", so pi finishes an edit/write batched in the same message before the plan is read. We checked pi's source back to 0.79.1 (our minimum), which honors the flag, so every supported version gets the fix. plannotator_mark_done doesn't need it. This will be in the next release.
Activity
fix(pi): run plannotator_submit_plan sequentially so it never reads a…
backnotprop commentedon Sep 28, 2026
Thanks @bugs-wkettlitz, great diagnosis. Your fix was right: #1623 marks
plannotator_submit_planasexecutionMode: "sequential", so pi finishes an edit/write batched in the same message before the plan is read. We checked pi's source back to 0.79.1 (our minimum), which honors the flag, so every supported version gets the fix.plannotator_mark_donedoesn't need it. This will be in the next release.