[Bug]: bug(opencode): unresolved approval requests remain after error turn and block settlement #7657
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/desktop
Steps to reproduce#
Summary#
Using OpenCode, when a turn ends in an error (content-blocked/runtime error path), approval prompts can remain
marked as pending in thread metadata (pending_approval_count > 0) even though the turn is terminal (state=error)
and no live user-input approval is actually waiting. This leaves chats in a “stuck awaiting approval” state.
What’s happening#
- Threads shown as unresolved approval state by UI.
projection_turnsentries for affected turns are instate='error'.- There are unresolved approval activities with no matching
approval.resolvedfor these turns. - In one thread, repeated
content-blockedprovider errors are visible in provider logs; requests are failing and no reconciliation seems to clear pending approvals.
Environment#
- Provider:
opencode - App mode: desktop (macOS, current)
- Observed on existing local state via
t3codeDB/logs
Repro (local evidence)#
- Run
opencodeprovider. - Trigger action leading to permission request + provider runtime failure (e.g.
content-blockedstyle error in provider session). - Observe the turn transitions to error/completed terminal state.
- Check DB/log evidence:
- pending approvals remain nonzero
- unresolved
approval.requestedactivity entries remain - no corresponding
approval.resolvedrows for affected request IDs.
- UI continues surfacing approval-like stale state instead of returning to normal done/error handling.
Actual behavior#
- Threads cannot settle / continue cleanly after error because stale pending approvals are not reconciled.
pending_approval_countdoes not reflect true runtime await state.
Expected behavior#
- Any terminal/error state should cancel or resolve outstanding approval requests deterministically.
- Thread/session status should settle consistently and not show “awaiting approval” when no approval interaction is active.
- Provider/runtime error paths should write symmetrical approval cleanup events.
Evidence (from local triage)#
thread_id:30bdf143-0409-4976-a934-01a33606e157(pending_approval_count=5)thread_id:4e318839-a01c-45a6-b814-9bebf4f098a2(pending_approval_count=7)thread_id:56ac7743-6ce2-4153-8f55-79c867708a5f(pending_approval_count=1)- provider events include repeated
session.error ... content-blocked (request id: ...)with same request ids reflected in failed turn completions.
Relevant areas to inspect#
apps/server/src/provider/...OpenCode provider adapter- approval projection writes (
projection_threads,projection_turns,projection_pending_approvals,projection_thread_activities) - session/turn reconciliation path in error/stop handlers
Suggested fix#
- On terminal/error completion for a run, reconcile every outstanding approval request for that run:
- mark as
resolved(cancelled/failure outcome) or remove from pending with clear state reason.
- mark as
- Gate UI pending-approval state from active runtime/request state, not only stale counters.
- Add regression test:
- inject
content-blockedruntime error - assert no unresolved approval rows after turn terminalization
- assert thread can accept next prompt post-recovery.
- inject
Expected behavior#
Expected behavior#
- Any terminal/error state should cancel or resolve outstanding approval requests deterministically.
- Thread/session status should settle consistently and not show “awaiting approval” when no approval interaction is active.
- Provider/runtime error paths should write symmetrical approval cleanup events.
Actual behavior#
Actual behavior#
- Threads cannot settle / continue cleanly after error because stale pending approvals are not reconciled.
pending_approval_countdoes not reflect true runtime await state.
Impact#
Major degradation or frequent failure
Version or commit#
0.0.34-nightly.20260820.1141
Environment#
- OS: macOS - App: T3 Code desktop - Provider/runtime: opencode
Logs or stack traces#
Thread state mismatch observed in local triage DB:
- projection_threads pending_approval_count:
- 30bdf143-0409-4976-a934-01a33606e157 -> 5
- 4e318839-a01c-45a6-b814-9bebf4f098a2 -> 7
- 56ac7743-6ce2-4153-8f55-79c867708a5f -> 1
- For these rows, approval activity has only `approval.requested` entries and no `approval.resolved`.
- matching turns are in terminal `state='error'`.
- provider/events.<thread>.log contains repeated `session.error` / `content-blocked` with request IDs:
- 2026082015592712693224565m68ArWMYlm1
- 20260820164922794879407dkckrBAd97b18
- ... (latest failure id in logs mapped to same turn)
Screenshots, recordings, or supporting files#
No response
Workaround#
Archiving the chat instead of settling
Xzese(GitHub profile, opens in a new tab) added labelsbug
Xzese(GitHub profile, opens in a new tab) added labelsneeds-triage
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Note
🤖 GPT-5.6 Sol in Codex responding on behalf of Theo
Closing as a duplicate of #7113. The same OpenCode approval remains pending after a failed turn.
Track the remaining work in #7113.