Repository navigation
fix(server): background subagents sharing an OpenCode 2 child session all finish - #16811
Abdullah1738 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe adapter now tracks which child execution consumes each subagent prompt. It uses that association and report descriptions to attribute reports and settle matching background calls. Replay tests cover shared child sessions, queued prompts, reconnects, and failures. ChangesShared subagent calls
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant OpenCode as OpenCode event stream
participant Adapter as OpenCode2AdapterV2
participant Calls as SubagentCall state
OpenCode->>Adapter: Enqueue a prompt for a child session
Adapter->>Calls: Associate a uniquely matching prompt with its inbox item
OpenCode->>Adapter: Deliver the inbox item
Adapter->>Calls: Record the child execution count
OpenCode->>Adapter: Report the child execution
Adapter->>Calls: Match the background call and settle calls for that execution
Suggested reviewers: Merge Risk: 🔵 Low · up to If a child run continues through a stream reconnect, one background call may remain running after the work finishes. This bounded edge case can be accepted with owner awareness or addressed before merge. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change is confined to how related background tasks finish and does not change existing access controls. Some recovery and repeated-message behavior still depends on delivery guarantees that were not established in this review. Retained concerns Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Note Grok responding on behalf of Julius. Thanks for digging into this, @Abdullah1738. The main case here, where OpenCode steers a second If you can still reproduce the other case, where a report naming a later background call on a shared child settles the wrong call, a small follow-up PR against the new adapter location with just that routing and its test would be very welcome. |
Problem
When an agent sends more than one
subagentcall to the same child session (resuming a subagent while it is still working, or mixing a foreground and a background call on it), the OpenCode 2 adapter can leave a background call running forever. The thread'spendingBackgroundTasksnever empties, so the thread keeps showing as working long after everything finished.Two ways this happens:
Seen on real threads: a background "Finish shared UI audit" call stayed running after its report settled an earlier foreground call on the same child, and a "Validate backfill edge cases" call whose prompt was steered into a running execution never got a report.
Change
descriptionin the report's<subagent>tag), falling back to the oldest background call on that child.If the adapter misses the events that tie a call to an execution, that call keeps the current behaviour and waits for its own report.
Scope and approval
This is a focused fix in
OpenCode2AdapterV2.ts: background subagents stuck as pending work when calls share a child session. It doesn't change any contract or the UI, so I didn't open an issue first. Happy to open one if you'd prefer.Verification
vp test run src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts: 90/90 pass.vp linton the changed files are clean.Built with Claude Opus 5.5 in T3 Code (reviewed with GPT 6 Astra).