Repository navigation
fix(server): stop silently dropping OpenCode child requests - #16870
Adamulek123 wants to merge 2 commits into
Conversation
OpenCode child permissions and questions disappeared after five routing retries, leaving the native request waiting without a visible failure. Keep the existing five-second backoff, then emit a warning and provider-session error. Reject permissions and questions only when the native parent chain proves this runtime owns them. Bound rejection delivery to ten seconds and keep failed rejections available for later routing. Ignore requests whose complete parent chain belongs to another runtime. The SDK supports both rejection paths, and OpenCode waits on these requests without a request timeout. Longer or unbounded retries only postpone the failure. Blind rejection can cancel another session on an external server, so unresolved ownership emits a failure without guessing who owns the request. Add deterministic clock and event tests for exhausted routing, failed and timed-out rejection, duplicate asks, late relations, externally settled requests, and unrelated sessions. Model: gpt-6.1-sol (Codex)
Routing retries overwrote an earlier unknown-root classification with transient lookup failures, allowing exhaustion to report a sibling request as a session error. Native rejection also treated an already-answered request as a delivery failure. Keep the observed foreign classification sticky through exhaustion. A failed lookup provides no new ownership evidence and must not overturn the earlier classification. Treat native NotFoundError as settled, so a later route cannot resurrect the answered request. Add TestClock regressions for permissions and questions, document the native permission rejection cascade, and clarify that an unknown root can also be an unregistered local root. Model: gpt-6.1-sol (Codex)
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a narrowly scoped OpenCode adapter bug fix that replaces silently abandoned child requests with ownership-aware error reporting and bounded native rejection. The production change is isolated and supported by comprehensive deterministic tests covering retries, late ownership, duplicate events, failed rejection, timeout, and already-settled requests. You can add or adjust custom eligibility rules. Learn more. |
|
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; 8 remain after this review. 📝 WalkthroughWalkthroughOpenCode request routing now distinguishes proven-foreign sessions from unresolved owner lookups. After retries, it leaves proven-foreign requests alone and rejects eligible permission or question requests for registered local threads. Tests cover retry and rejection outcomes. ChangesOpenCode request routing
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant Adapter as OpenCodeAdapterV2
participant Native as OpenCode native API
participant Session as Provider session
Adapter->>Native: Reject permission or question request
Native-->>Adapter: Rejection result
Adapter->>Session: Record routing or rejection error
Suggested reviewers: Merge Risk: 🔵 Low · up to An unroutable permission can occasionally cancel another pending permission and fail its tool call. This is a bounded risk to accept or address when merging. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Automatic rejection is guarded by locally recognized session ownership and does not demonstrate an authorization bypass. A remaining failure-containment risk is that background rejection can overlap a new turn and affect permissions or error status after that turn starts. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error)
✅ Passed checks (4 passed)
Full details: ApprovabilityExplanation The pull request changes an external side effect in
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai which checks failed |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
gh pr view 16870 --repo pingdotgg/t3code --json url,headRefOid,statusCheckRollup,bodyLength of output: 13674
The PR description reports two local validation failures, separate from GitHub CI:
You are interacting with an AI system. |
Problem
When OpenCode's child request cannot reach an active owning turn, the adapter retries five times and then silently drops its routing work. The native permission or question can remain blocked while the client shows no prompt. A maintainer confirmed this path in #16846.
Change
After the existing five-second backoff:
Successful rejection settles the request. A native
NotFoundErroralso settles it without marking the session errored, since another caller may already have answered it. Failed rejection leaves it unsettled so a later replay can route it.OpenCode permission rejection cancels every pending permission in the asking native session. Its SDK has no single-request denial. Question rejection affects only the named question. This behavior is documented at the call site.
Only
OpenCodeAdapterV2.tsand its tests change. The shared server path applies to web, desktop, and mobile clients; OpenCode2 is unchanged and covered by its adapter suite. No contract or configuration changes. #15778 addresses recovery and detach rather than this inline routing path.Validation
OpenCodeProvider.test.ts: 172 passed, one failed. The failure asserts a POSIX credential path against a Windows path in unchanged code; the implementation agent also reproduced it before this follow-up.TestClockto cover exhaustion, duplicate events, late ownership, settled requests, SDK failure and timeout, unknown-root lookup failures, and already-answered races. The implementation agent reports independent mutation checks for the rejection cases and all four follow-up cases.layerwarning. Whitespace checks pass.Limits
Ownership that remains unresolved can still leave a request waiting natively. A warning and session error expose lookup failures; an unregistered root is deliberately ignored to avoid interfering with another runtime. The fix does not add automatic replay when routing work ends.
Tests use mocked SDK clients. No live OpenCode process or client verification was run.
Implemented with gpt-6.1-sol through the Codex harness.