fix(server): recover OpenCode turns from live busy status - #11640
hugojosefson wants to merge 1 commit into
Conversation
Read the live OpenCode status before recovery after an idle or error event. Start one active turn when the server reports busy work. Keep user Stop active during recovery. Tests include stale status, duplicate busy events, completion, and Stop during recovery.
Bugbot is paused — on-demand spend limit reachedBugbot uses usage-based billing for this team and has hit its on-demand spend limit. A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe OpenCode adapter now recovers eligible busy or retry sessions when no turn is active. Tests cover recovery conditions, replacement turn state, preserved session states, cleanup, and interruption during pending status recovery. ChangesOpenCode busy-turn recovery
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant OpenCode
participant OpenCodeAdapter
participant ProviderSession
OpenCode->>OpenCodeAdapter: Send busy or retry session.status
OpenCodeAdapter->>OpenCode: Poll session.status
OpenCodeAdapter->>ProviderSession: Create active turn and set running
OpenCodeAdapter->>ProviderSession: Emit turn.started
Merge Risk: ⚪ Minimal · up to The recovery path safely abandons a live-status check when it cannot obtain a result, with no concrete merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Note 🤖 GPT-6 Astra responding on behalf of hugojosefson I examined the docstring coverage warning. The isolated development check passed on commit |
Note
🤖 Prepared by GPT-6 Astra on behalf of hugojosefson
OpenCode can report busy after T3 Code records a turn as
completedorfailed. The adapter ignores that status whenactiveTurnIdis missing. Output can continue while T3 shows Idle and has no active-turn protection from session cleanup.On a parent-session busy or retry event, this change checks live OpenCode status before it creates one active turn. It rechecks session ownership, generation, and cancellation after the request. User Stop prevents recovery. No status polling is added.
This corrects recovery after a terminal state. #10805 prevents completion before work ends. This PR applies directly to
main. It works without the changes from #10805.Validation:
77bca8b2and passed with this correction.git diff --checkpassed.The PR build at
881f9db897733181227fede49aa45d97124dc972passed an isolated development check on September 13, 2026. The compiled server used a new database and a synthetic OpenCode HTTP/SSE server. Commands and state updates used the actual T3 WebSocket API.Live checks:
runningwith a new active turn after verified busy status.runningafter verified busy status.interruptedwith no active turn.The unchanged client helpers received actual WebSocket session states. They returned Working and the correct Stop command during recovered work. That Stop command produced the abort result above. After Stop, the helpers returned no Stop command.
The check used event receipts, with timeouts only as failure limits. It did not use private data or model inference. No new browser or desktop rendering check was performed.
Server artifact SHA256:
A stable
v0.0.40build with this correction and #10805 completed an unattended turn of about 69 minutes with two compactions. T3 showed Working with a Stop button, work continued after compaction, and the turn finished. This is live desktop evidence for the combined build. The isolated development check above used only this PR onmain.If the live status request fails, recovery waits for another busy event. Intentional Stop remains authoritative until a new T3 turn clears that state.
Model: GPT-6. Harness: Codex.
Summary by CodeRabbit