Handle OpenCode subagent resumption#66
Conversation
|
Wondering what really moved? Review this PR in Change Stack to inspect semantic changes, definitions, and references. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesResumption waiting logic
🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/server/src/provider/Layers/OpenCodeAdapter.test.ts`:
- Around line 3001-3122: Add a second focused regression test (or extend the
existing "waits for provider resumption when background subagents cause
premature idle then completes on real idle") that reproduces a repeated
idle/resume window: use the same createSubscribedEventQueue /
createMockOpenCodeRuntime and OpenCodeAdapter usage, startSession and sendTurn,
then push events in this order — a tool-call finished message, a session.idle to
trigger the first waiting window, a session.status {type: "busy"} to resume,
immediately another session.idle while the adapter is now in the
resumed-but-still-on-turn state to trigger a second waiting window, another
session.status {type: "busy"} to clear it, then a final assistant message with
finish: "end_turn" and a final session.idle to complete the turn — and assert
that the adapter emits the corresponding lifecycle events and emits two distinct
runtime.warning entries (or otherwise records two waiting windows) before
turn.completed; target the OpenCodeAdapter.startSession / sendTurn and
adapter.streamEvents event sequence when implementing the pushes and assertions.
In `@apps/server/src/provider/Layers/OpenCodeAdapter.ts`:
- Around line 2992-3016: The legacy idle watchdog (deferPrematureIdleCompletion)
must not run while a turn is already in resumption waiting state; modify the
idle handling in OpenCodeAdapter so that when
context.activeTurnWaitingForResumption is true you skip calling yield*
deferPrematureIdleCompletion and avoid starting the old 10s failure path—ensure
the existing branch that sets context.activeTurnWaitingForResumption,
context.activeTurnResumptionStartedAt and calls yield* scheduleResumptionTimeout
remains the only path taken in that case; apply the same guard around calls to
deferPrematureIdleCompletion in the other similar blocks (the ones near where
scheduleResumptionTimeout, deferPrematureIdleCompletion, and
context.activeTurnWaitingForResumption are referenced).
- Around line 2219-2230: The watchdog uses context.activeTurnResumptionStartedAt
but never binds to a specific epoch, so a stale timeout can cancel a newer wait;
fix scheduleResumptionTimeout by reading and storing the current
context.activeTurnResumptionStartedAt (or a new local "resumptionEpoch") at the
moment you schedule the Effect, then in the timeout handler verify that the
stored epoch still equals context.activeTurnResumptionStartedAt in addition to
the existing checks (context.stopped, context.activeTurnId,
context.activeTurnWaitingForResumption); do the same epoch-capture/compare
pattern for the other similar watchdogs referenced in this file to ensure each
timeout is tied to the exact waiting window.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 71fb5298-e3a0-4601-9c72-0911658ed8be
📒 Files selected for processing (2)
apps/server/src/provider/Layers/OpenCodeAdapter.test.tsapps/server/src/provider/Layers/OpenCodeAdapter.ts
Summary
Verification
Summary by CodeRabbit
Bug Fixes
Tests