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
fix(acp): a lost or locked Copilot session restarts on the next message instead of failing every time - #26651
Sometimes GitHub Copilot CLI (ACP Registry agent github-copilot-cli) rejects session/prompt with JSON-RPC -32603 and one of these causes:
session event delivery failed: session not found: <id> (inside Request session.send failed with message: …)
session lock unavailable during is_session_generation_current: acquisition timed out
Where the cause appears depends on the Copilot version. Copilot's older TypeScript ACP layer sends message: "Internal error" with the cause in data.details. Its native ACP layer, used by 1.0.105 (the version the ACP Registry installs), puts the text in message and sends no data; for example, a real 1.0.105 session/prompt failure on the same session.send path came back as {"code":-32603,"message":"Request session.send failed with message: Session directory no longer exists: <path>"}.
When that happens, that Copilot process fails every later prompt in the thread the same way. T3 keeps sending each new message to the same broken process, so the thread can't be used until T3 Code restarts. Restarting works because a new Copilot process can still session/load the saved conversation. The lock-timeout string matches a public Copilot CLI report of the same stuck-session state on Copilot 1.0.103 (github/copilot-cli#5253).
Expected: the next message starts a new Copilot process, reloads the saved session and runs normally.
Repro: use Copilot through the ACP Registry provider until Copilot returns one of the errors above. T3 shows the provider's error ("Internal error" on the older shape). Every message you send after that fails with the same error until you restart T3.
Change
packages/provider-acp/src/server/adapter.ts: a new optional flavor hook, restartRuntimeAfterPromptError(error). If a prompt fails, was not interrupted, and the hook returns true, the adapter sets the existing runtimeRestartRequired flag. The next startTurn already acts on that flag through restartRuntimeAfterTeardownIfRequired: it spawns a new runtime and calls session/load for the thread's native session id. Grok's interrupt restarts and process-exit recovery use the same path. The failed turn is not retried automatically, and its failure message is unchanged.
packages/provider-acp-registry/src/server/copilotAcp.ts and adapter.ts: isCopilotLostSessionError matches only a session/promptAcpRequestError with code -32603 whose message or data.details contains one of the two causes above. It is wired into the existing Copilot-only flavor block, so other Registry agents and other Copilot errors keep their current behavior.
Scope and approval
There is no prior issue or discussion. I think this qualifies as a very small, focused fix for an obvious bug:
Defect: after one provider-side session failure, the thread can't be used until an app restart. Nobody would choose that behavior.
Fix: it reuses the restart-and-reload path the adapter already has for Grok interrupts and process exits. The only change is that one more condition sets the existing flag. No new state, contract, setting, UI or product behavior is added.
Scope: it only applies to Copilot and only to two specific error causes. One problem, 4 files, about 32 lines of source plus one table-driven test (5 rows).
Kept out: other Copilot reliability work from the same fork is not included. That covers turn-completion gating, background-subagent handling and surfacing the provider's error details. Those are separate problems.
Verification
Test, at the lowest layer that fails on main. It drives the real ACP Registry adapter with replay-agent subprocesses. Each matched cause has two rows, one per error shape (data.details and message). For those, process 1 fails the prompt and process 2 expects initialize, session/new, session/load {sessionId: "copilot-session"}, then session/prompt. A fifth row fails the prompt with the real unrelated 1.0.105 error above ("Session directory no longer exists") and expects the next prompt on the same process, so the test also fails if the match ever broadens to every internal error (checked by temporarily making the matcher return true).
cd apps/server
vp test run src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts -t "runs Copilot's next message"
On main (source changes stashed): all four restart rows fail with expected 'failed' to equal 'completed'. The second message goes back to the same process and fails again. The unrelated-error row passes, as it should.
A matcher that only reads data.details fails both message-shape rows, which is the 1.0.105 case.
With the fix: all five rows pass, and so do the whole file and the neighbouring AcpAdapterV2.test.ts (110 tests across the two files).
vp run check:changed upstream/main: format, lint, knip, graphql, typecheck (13 packages) and tests all pass.
Runtime transcript: the same scenario with ACP protocol logging turned on (only the decoded frames, payloads shortened). This is the lock-timeout row.
Before (main):
[agent process 1] T3 -> agent session/prompt {sessionId: "copilot-session", ...}
[agent process 1] agent -> T3 Failure {code: -32603, message: "Internal error", data: {details: "session lock unavailable during is_session_generation_current: acquisition timed out"}}
[T3] turn 1 terminal status: failed
[agent process 1] T3 -> agent session/prompt {sessionId: "copilot-session", ...} <- same process reused
[agent process 1] agent -> T3 Failure {code: -32603, ...}
[T3] turn 2 terminal status: failed; agent processes spawned: 1
After:
[agent process 1] T3 -> agent session/prompt {sessionId: "copilot-session", ...}
[agent process 1] agent -> T3 Failure {code: -32603, message: "Internal error", data: {details: "session lock unavailable during is_session_generation_current: acquisition timed out"}}
[T3] turn 1 terminal status: failed
[agent process 2] T3 -> agent initialize
[agent process 2] T3 -> agent session/new
[agent process 2] T3 -> agent session/load {sessionId: "copilot-session", ...}
[agent process 2] T3 -> agent session/prompt {sessionId: "copilot-session", ...}
[agent process 2] agent -> T3 Success {stopReason: "end_turn"}
[T3] turn 2 terminal status: completed; agent processes spawned: 2
In the "before" run the replay agent answers the second prompt with a mismatch error, because its transcript doesn't expect a second prompt. On a real Copilot process that second response is the same -32603 error again.
Not checked:
I didn't reproduce either cause against a live Copilot CLI. I looked for a way to trigger them on demand and found none: a second process loading the same session, concurrent prompts and cancels, /compact, and closing then prompting all left the session usable. The two causes come from failures captured while using Copilot through T3 in a fork, on the older error shape; the lock-timeout one also appears in the public report linked above, from a 30-hour session. Their 1.0.105 shape is inferred from the captured session.send failure above, not observed. The match is on these specific causes, so if Copilot rewords them, the code falls back to the current behavior instead of restarting too often.
I didn't check that a live Copilot always loads the session successfully after the restart. If session/load fails, the next turn reports that failure through the existing activation path, as it already does for Grok and process-exit restarts.
Written by Opus 5.5 with Claude Code. Reviewed by GPT 6.1 Sol: 3 rounds, verdict approved.
Macroscope's review found this PR approvable — Copilot sessions encountering two specific lost-session errors will replace the runtime before subsequent use, reusing existing session recovery. The narrow trigger leaves unrelated failures unchanged and does not automatically replay failed prompts.
You can add or adjust custom eligibility rules. Learn more.
Limit details: You’ve used all 10 included reviews currently available.
Walkthrough
The ACP adapter now supports restarting a runtime after selected prompt errors. Copilot routing uses this behavior for recognized session failures. Regression tests cover those failures and an unrelated internal error.
AcpAdapterV2Flavor adds an optional predicate for prompt errors that require runtime replacement. The prompt-error handler invokes it for non-interruption failures and uses the squashed cause for failure mapping.
Copilot error classification and routing packages/provider-acp-registry/src/server/copilotAcp.ts, packages/provider-acp-registry/src/server/adapter.ts, apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts
Copilot routing supplies a predicate that recognizes specified session failures. Tests check that these errors trigger runtime replacement, while an unrelated internal error uses the same runtime.
No concrete merge-blocking defect was established in the reviewed change.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title clearly and concisely describes the main change: restarting Copilot after lost-session or lock errors so the next message can recover.
Description check
The description covers the Problem, Change, Scope and approval rationale, and Verification sections. It includes reproduction context, implementation details, focused test results, limitations, and th…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description covers the Problem, Change, Scope and approval rationale, and Verification sections. It includes reproduction context, implementation details, focused test results, limitations, and the claimed agent disclosure.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.
…ge instead of failing every time
When Copilot answers session/prompt with -32603 and "session event delivery
failed: session not found" or "session lock unavailable ... acquisition timed
out", its process keeps failing every later prompt the same way. The ACP
adapter kept reusing that process, so the thread stayed broken until T3
restarted.
ACP flavors can now name prompt errors that need a fresh process. Copilot
flags these two, so the next message spawns a new runtime and reloads the
saved native session before prompting.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Limit the match to the reported failure, not any nested diagnostic.
A session/prompt error with code -32603 can describe another failure while quoting a previous session event delivery failed: session not found: ... error. includes classifies that message as a lost session and replaces the runtime unnecessarily. Match the observed outer error form or a delimited cause instead of searching all diagnostic text. Based on learnings, external error-message matchers should use observed strings or defined tokens rather than loose substring matches.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Updated the original branch at 903a66033e, preserving ianrowe12's implementation and commits. Merged current main and simplified data.details parsing with the file's existing record() helper. The final diff is still four files, with one fewer source line than the original.
Verified through Blacksmith:
Current main (e5909e53c3): all four recovery cases fail on the second turn; the unrelated-error control passes.
Updated branch: both ACP adapter suites pass, 110 tests total.
vp run check:changed e5909e53c32a9d5b51caf6352d1f17fd73e86db7 passes format, lint, both knip checks, GraphQL, typechecks for 13 affected packages, and 29 scoped tests.
Two independent reviews of the final head found no blocking issues.
The subprocess protocol cases verify this sequence: first prompt fails; the next message starts process 2, initializes it, loads copilot-session, and completes its prompt. The unrelated internal error completes the next message on process 1. Failed work is never replayed.
Unverified: reproducing either error with a live Copilot CLI and its subsequent session reload. These errors are not reliably inducible. This changes the shared provider adapter, with no client UI changes.
The previous bot concern about quoted nested diagnostics has no observed Copilot example. The matcher requires session/prompt, -32603, and one of the two exact diagnostic markers; narrowing the accepted wrappers without provider evidence could reject valid failures. Keeping the original matching scope.
All 29 checks on 903a66033e are green, the PR is mergeable, and the latest bot review generated no actionable comments.
partial verification at 903a66033e5644ac672b7984d6d1642e9426a2af. the changed error-triggered recovery is still unverified.
ran vp i and a background vp run dev on github/main (15fe283272) in a separate worktree, then stopped it before starting the exact pr head. used playwright from the repo with /usr/bin/google-chrome on linux. created the project and threads through the web app, pointing at a real git repository. all runtime turns used real providers, with no replay or injected failures.
codex gpt-6.1-sol completed on main. on the pr head, its saved conversation resumed and correctly recalled its earlier response.
installed copilot 1.0.105 through settings -> add provider -> acp registry. a real copilot prompt completed on main. stopped a running sleep 120 using the client, then sent another message in the same thread. it completed with COPILOT_FOLLOWUP_OK.
on the pr head, the saved copilot conversation loaded in the new server process and completed with PR_COPILOT_RESUMED_OK. repeated stop and follow-up successfully.
short transcript from the real provider event log and client:
main: session/prompt succeeded -> COPILOT_OK
main: sleep 120 -> client Stop -> Run interrupted
main: next session/prompt succeeded -> COPILOT_FOLLOWUP_OK
pr 20:13:27.685Z session/load started
pr 20:13:28.308Z session/load succeeded
pr 20:13:28.432Z session/prompt started
pr 20:13:31.658Z session/prompt succeeded -> PR_COPILOT_RESUMED_OK
pr: sleep 120 -> client Stop -> Run interrupted
pr: next session/prompt succeeded -> COPILOT_FOLLOWUP_OK
also ran the existing AcpRegistryAdapterV2.test.ts and AcpAdapterV2.test.ts through blacksmith: 110 tests passed. those replay-based tests support the implementation but do not prove live error recovery. the head has 29 successful ci checks, none pending or failing. no source changes or pushes.
main, stop and follow-up:
pr head, saved-session resume and repeated stop and follow-up:
Not verified
neither targeted lost-session nor lock-timeout error occurred on main or the pr. therefore the original bug was not reproduced, and the new restartRuntimeAfterPromptError trigger, replacement process, and subsequent saved-session reload after either error were not exercised against live copilot. normal resume and cancellation are neighboring behavior, not proof of that fix. both recordings show those neighboring checks only.
the older data.details error shape, unrelated internal-error process retention, native desktop/mobile clients, windows/macos, relay/tunnel connections, and multi-device operation were not exercised. this pass does not establish that the changed behavior works in production.
…ge instead of failing every time (pingdotgg#26651)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: maria-rcks <maria@kuuro.net>
(cherry picked from commit 28bfae0)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:M30-99 changed lines (additions + deletions).vouch:unvouchedPR author is not yet trusted in the VOUCHED list.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Sometimes GitHub Copilot CLI (ACP Registry agent
github-copilot-cli) rejectssession/promptwith JSON-RPC-32603and one of these causes:session event delivery failed: session not found: <id>(insideRequest session.send failed with message: …)session lock unavailable during is_session_generation_current: acquisition timed outWhere the cause appears depends on the Copilot version. Copilot's older TypeScript ACP layer sends
message: "Internal error"with the cause indata.details. Its native ACP layer, used by 1.0.105 (the version the ACP Registry installs), puts the text inmessageand sends nodata; for example, a real 1.0.105session/promptfailure on the samesession.sendpath came back as{"code":-32603,"message":"Request session.send failed with message: Session directory no longer exists: <path>"}.When that happens, that Copilot process fails every later prompt in the thread the same way. T3 keeps sending each new message to the same broken process, so the thread can't be used until T3 Code restarts. Restarting works because a new Copilot process can still
session/loadthe saved conversation. The lock-timeout string matches a public Copilot CLI report of the same stuck-session state on Copilot 1.0.103 (github/copilot-cli#5253).Expected: the next message starts a new Copilot process, reloads the saved session and runs normally.
Repro: use Copilot through the ACP Registry provider until Copilot returns one of the errors above. T3 shows the provider's error ("Internal error" on the older shape). Every message you send after that fails with the same error until you restart T3.
Change
packages/provider-acp/src/server/adapter.ts: a new optional flavor hook,restartRuntimeAfterPromptError(error). If a prompt fails, was not interrupted, and the hook returns true, the adapter sets the existingruntimeRestartRequiredflag. The nextstartTurnalready acts on that flag throughrestartRuntimeAfterTeardownIfRequired: it spawns a new runtime and callssession/loadfor the thread's native session id. Grok's interrupt restarts and process-exit recovery use the same path. The failed turn is not retried automatically, and its failure message is unchanged.packages/provider-acp-registry/src/server/copilotAcp.tsandadapter.ts:isCopilotLostSessionErrormatches only asession/promptAcpRequestErrorwith code-32603whosemessageordata.detailscontains one of the two causes above. It is wired into the existing Copilot-only flavor block, so other Registry agents and other Copilot errors keep their current behavior.Scope and approval
There is no prior issue or discussion. I think this qualifies as a very small, focused fix for an obvious bug:
Verification
Test, at the lowest layer that fails on
main. It drives the real ACP Registry adapter with replay-agent subprocesses. Each matched cause has two rows, one per error shape (data.detailsandmessage). For those, process 1 fails the prompt and process 2 expectsinitialize,session/new,session/load {sessionId: "copilot-session"}, thensession/prompt. A fifth row fails the prompt with the real unrelated 1.0.105 error above ("Session directory no longer exists") and expects the next prompt on the same process, so the test also fails if the match ever broadens to every internal error (checked by temporarily making the matcher return true).main(source changes stashed): all four restart rows fail withexpected 'failed' to equal 'completed'. The second message goes back to the same process and fails again. The unrelated-error row passes, as it should.data.detailsfails bothmessage-shape rows, which is the 1.0.105 case.AcpAdapterV2.test.ts(110 tests across the two files).vp run check:changed upstream/main: format, lint, knip, graphql, typecheck (13 packages) and tests all pass.Runtime transcript: the same scenario with ACP protocol logging turned on (only the decoded frames, payloads shortened). This is the lock-timeout row.
Before (main):
After:
In the "before" run the replay agent answers the second prompt with a mismatch error, because its transcript doesn't expect a second prompt. On a real Copilot process that second response is the same
-32603error again.Not checked:
/compact, and closing then prompting all left the session usable. The two causes come from failures captured while using Copilot through T3 in a fork, on the older error shape; the lock-timeout one also appears in the public report linked above, from a 30-hour session. Their 1.0.105 shape is inferred from the capturedsession.sendfailure above, not observed. The match is on these specific causes, so if Copilot rewords them, the code falls back to the current behavior instead of restarting too often.session/loadfails, the next turn reports that failure through the existing activation path, as it already does for Grok and process-exit restarts.Written by Opus 5.5 with Claude Code. Reviewed by GPT 6.1 Sol: 3 rounds, verdict approved.