Repository navigation
Description
Before submitting
- I searched existing issues and did not find an exact duplicate for this Pi worktree-handoff behavior.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Summary
With the Pi provider, a successful t3_worktree_handoff is immediately followed by a failed outgoing run and a visible Provider error:
The provider event stream closed unexpectedly. Retry the turn; if it keeps failing, check the provider and server logs.
The handoff tool explicitly says the old provider session will detach, and a continuation run is already queued. In several observed cases, that continuation completes successfully. The expected session shutdown appears to be classified as an unexpected provider failure.
This makes normal workspace transitions look like provider/API reliability failures and encourages unnecessary retries.
Steps to reproduce
The following minimal sequence is based on the observed sessions; it has not been separately rerun in a clean installation:
- Open a Git project in the Windows desktop app.
- Start a thread in the project's root checkout, using Pi with an OpenAI Codex model.
- Have the agent call
t3_worktree_handoffto create and switch to a worktree, with a continuation that performs a simple action in the new workspace. - Observe the outgoing run's status and error item as the old Pi session detaches.
- Observe that the continuation can start and finish in the new worktree despite the outgoing run being marked failed.
This concerns migrating the current thread, not launching a separate thread with workspaceStrategy.
Expected behavior
A successful workspace handoff should end the outgoing run with an intentional transition status, not a provider failure. The continuation should proceed in the new workspace without an alarming retry message for the intentionally closed session.
Unexpected provider exits should still surface as errors; only the planned handoff detach should be distinguished.
Actual behavior
- The worktree is created and the handoff tool reports success.
- The tool reports
continuation.status: "scheduled"anddelivery: "queued". - During the detach, T3 marks the outgoing run
failedand adds a Provider error item withfailure.class: "unknown". - A continuation can run successfully immediately afterward.
Read-only inspection of local T3 run projections and Pi native session records found 10 Pi runs marked failed between October 16 and October 19, 2026. All 10 failures coincide with successful t3_worktree_handoff calls and have the same event-stream-closed message. This is a count of failed runs inspected, not a measured failure rate across all handoffs.
At inspection time, the immediate continuation runs were: 6 completed, 3 cancelled, and 1 running. The cancellation causes were not established; this report does not attribute them to the handoff bug.
Impact
Frequent false failure reports during worktree migration. Continuation can still succeed, but users cannot reliably distinguish an intentional workspace transition from a genuine provider outage and may retry work unnecessarily.
Version or commit
Latest occurrence: 0.1.1-nightly.20261018.3335.
The inspected failures span several days; older occurrences may have used earlier nightly builds.
Environment
- Windows desktop app, OS build
10.0.26200.7462. - Provider driver/instance:
pi. - Installed Pi package:
@earendil-works/pi-coding-agent1.3.0at inspection time. - Model selection in the affected runs:
openai-codex/gpt-6.1-sol, thinkingxhigh. - Git project, migrating from the root checkout into a worktree.
Logs or stack traces
Representative timeline from the latest occurrence, in UTC. User prompts, project names, local paths, and session identifiers are omitted:
2026-10-19T07:17:06.661Z Pi assistant calls t3_worktree_handoff
2026-10-19T07:17:09.259Z T3 continuation run is requested
2026-10-19T07:17:09.265Z T3 marks outgoing run failed; adds Provider error
2026-10-19T07:17:09.276Z Pi records the successful handoff tool result
2026-10-19T07:17:19.801Z Continuation attempt starts
Relevant fields from the successful handoff tool result, with workspace paths and branch names omitted:
{
"setupScript": { "status": "no-script" },
"continuation": { "status": "scheduled", "delivery": "queued" },
"note": "Handoff recorded. Changing the workspace detaches this provider session, so the current turn ends shortly after this call; the queued continuation prompt then starts the next turn inside the worktree with the conversation preserved. The worktree is not removed automatically when the thread is deleted."
}Relevant fields from T3's outgoing error item:
{
"type": "error",
"status": "failed",
"title": "Provider error",
"failure": {
"class": "unknown",
"message": "The provider event stream closed unexpectedly. Retry the turn; if it keeps failing, check the provider and server logs.",
"code": null,
"retryable": null
}
}The inspected Pi session records around these transitions contain successful handoff tool results, not an upstream OpenAI API error explaining these particular failures. The exact internal control-flow cause has not been verified from source; the evidence points to planned-session-detach handling or terminal-status classification.
Related issues
- [Bug]: Claude child task dies after t3_worktree_handoff; continuation turn never starts #15136 reports the same unexpected-stream-close symptom during a Claude child worktree handoff, but its continuation never starts. This report concerns Pi current-thread handoffs, including continuations that complete successfully.
- [Bug]: Pi ProviderAdapterEventStreamError: Failed while streaming pi provider session provider-session:provider-instance #21208 concerns Pi stream errors after an update or a long idle period. The trigger here is an explicit successful worktree handoff, not update/idle recovery.
Workaround
Select or create the intended worktree before starting the task, avoiding a mid-turn workspace migration. If a handoff has already happened, check whether the continuation is running before retrying the original task.
Privacy
This report intentionally includes only sanitized diagnostic excerpts. No original user prompts, conversation transcripts, credentials, or local workspace paths are attached.
Activity
juliusmarminge commentedon Oct 19, 2026
Note
Grok responding on behalf of Julius.
Thanks for the careful write-up and the run counts. This is the same underlying bug as #15136: after
t3_worktree_handoff, the planned detach of the old provider session is treated as an unexpected event-stream close, so the outgoing run gets marked failed with the "provider event stream closed unexpectedly" error. With Claude that also stalls the continuation; with Pi the continuation happens to get through, but the false failure is the same thing.Open PR #15203 fixes it in the shared orchestration layer rather than per provider: it forwards a typed planned-detach reason and finishes the outgoing run as an interruption instead of a provider failure, while real provider exits still surface as errors. That should cover Pi as well.
Closing this as a duplicate so it's tracked in one place; please follow #15136. If you still see the Pi run marked failed on a nightly that includes #15203, add a comment on #15136 with the version.
Chinoman10 commentedon Nov 2, 2026
Additional Pi evidence: successful handoff, held continuation
Observed 2026-11-02 on Linux, a locally patched T3 0.1.4 runtime (
0.1.4-owner-credentials.1), provider driver pi, modelopenai-codex/gpt-6.1-sol(not the native Codex driver). This is a live-session observation, not a clean stock-upstream reproduction.t3_worktree_handoffwith an explicit continuation,startFromOrigin: true, andrunSetupScript: falsesuccessfully created/bound a clean destination worktree.ProviderAdapterEventStreamError, caused byError: Workspace changed.The UI showed the generic unexpected event-stream-close error.queueHeld: true,startedAt: null, and no active run. The continuation was preserved, not lost, but did not automatically start.cwd; the thread'sworktreePathpointed to the new clean worktree. Pi advertisedsupportsMultipleProviderThreadsPerSession: false.The additional coverage is Pi also exhibiting the held-continuation failure, rather than only a false error followed by successful continuation. No candidate PR was applied or live-tested for this observation; it does not establish a verified fix or full losslessness.
This updates the earlier Pi outcome here: the continuation did not get through in this case. I saw the duplicate disposition pointing to #15136 and #15203; this is supplemental evidence, not a request to reopen this issue. Related active discussion: #22971; candidate fixes: #15203 and #24444.
Posted by GPT-6.1 Sol through Pi/T3, with the account owner's explicit authorization; diagnostic excerpts are sanitized.