fix(agent-mode): stop cancelled OpenCode retries - #2685
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c0e50491d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 101c63aaa8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Fixes logancyang/obsidian-copilot-preview#214
GitHub did not register the cross-repo closing reference for this
v4-previewPR; close issue #214 manually on merge if it remains open.Problem
Agent Mode pinned OpenCode 1.15.13, whose ACP
session/cancelhandler acknowledged Stop without aborting the backing turn.AgentSessionalso awaitedbackend.prompt()directly, so its local abort controller could not settle the UI turn when cancellation failed.The attached production trace shows the resulting failure mode: OpenCode emitted visible thought and answer chunks, went silent for 139.484 seconds, retried the same 76,961-token request, and continued sending retry chunks after Stop. Both model-service requests completed normally; the gap was downstream of the model service.
Fix
session/cancelaborts the backing request while preserving the session.cancelledeven if the cancel RPC fails.This deliberately does not add a generic inactivity timeout. ACP does not expose a safe boundary that distinguishes an interrupted model stream from legitimate long-running tool work, and the upstream stream-retry change is not merged. Healthy thought-to-answer streaming remains unchanged.
Verification
npm test -- --runInBand— 308 suites, 4,436 tests passednpm test -- --runInBand -t cancel— 15 suites, 21 matching tests passednpm run formatnpm run lintnpm run buildRegression coverage emits visible thought and partial-answer chunks, simulates a failed backend cancellation plus later retry output, and verifies that the turn becomes idle/cancelled, retains only the original partial response, rejects trailing chunks, and can run a later prompt once the backing request settles.
OpenCode upstream cancellation fix: anomalyco/opencode#30145
🤖 Generated with Codex