fix(opencode): Full access subagents start without approval prompts #35401
main fromrefs/pull/35401/head·merged by maria-rcks View on GitHubOpenCode 1.19.5's task tool builds a child session's permission from only the parent's deny and external_directory rules (agent/subagent-permissions.ts), and a running child reads its session once, so T3's post-creation session.update never reached the child. In Full access the parent's only rule was * * allow, so the child fell back to the agent default external_directory: ask and prompted. openCodePermissionRules now returns * * allow plus an explicit external_directory * allow for Full access. OpenCode copies that rule into the child at creation, before its first tool call. Parent behaviour is unchanged, and openCodeChildPermissionRules already treats the copied rule as inherited, so the follow-up rewrite does not duplicate it. Verified against a real opencode serve 1.19.5 with the hub's gpt-6-luna: with the old rules the @general child was created with [task deny] and asked external_directory for /tmp/.../outside/*. With the new rules the child was created with [external_directory allow, task deny] and completed cat on the outside file with no permission request. No new regex or parser.
Fixes pingdotgg/t3code#35246
Reproduction on main#
Commit fd8e386f7f (origin/main). Ran T3CODE_DEV_SEED=0 vp run dev in a fresh worktree, paired the web client in the preview browser, added a scratch git repo as a project, added the OpenCode provider in Settings > Providers (detected v1.19.5, authenticated) and picked OpenCode GPT-6 Luna, with the thread in the default Full access mode. (Claude models through OpenCode failed with a provider tool-schema error, unrelated.) Prompt: 'Use the task tool to launch a @general subagent ... run cat /tmp/<scratch>/outside/notes.txt and git -C <project> log --oneline'. OpenCode's log: parent session created with [{ allow}]; child created with only [{task deny}]; 4 s later `evaluated permission=external_directory pattern=/tmp//outside/ action.action=askandasking id=per_... permission=external_directory`. OpenCode's database then held [{task deny},{ allow},{task deny}] for the child (written by T3's session.update), but the running child never used it. In the T3 UI the subagent item 'Run requested shell commands' showed 'Waiting for approval · Decline · Approve' on the outside path, and the thread showed 'Approval' in the sidebar, although the thread was in Full access. In the OpenCode 1.19.5 source, SessionPrompt.run reads the session once before its step loop (session/prompt.ts:1085), and the task tool (tool/task.ts + agent/subagent-permissions.ts) copies only the parent's deny and external_directory rules into the child.
Evidence#
Configured OpenCode 1.19.5 in two fresh web-app environments. With Full access selected, submitted the same prompt asking a task-tool @general subagent to read a synthetic file outside the project and run git log. No approval was granted.
| Before | After |
|---|---|
| 4e48d9e6a5 | f4816f9a95 |
![]() | ![]() |
![]() | ![]() |
| Before recording | After recording |
Environment: Linux, Chromium preview browser, light theme, 1280×800 CSS pixels; separate fresh databases with development seeding disabled. Captures were inspected before upload. Private provider metadata is masked and the machine panel is cropped out; stills also mask changing elapsed counters. Eight seconds of initial loading were trimmed equally from both recordings.
Reproduction driver · Seed script · Capture notes · Runtime summary · Provider permission evidence
AI-assisted; verified with the tests and tools listed above.
Not shown:
- The @explore variant was not exercised; both comparisons used the reported @general reproduction.
- Desktop, mobile, and other OpenCode versions were not exercised; this proof covers the web client with OpenCode 1.19.5.
Tests#
vp test run src/server/adapter.test.ts in packages/provider-opencode: 54 passed. The new assertion in 'maps runtime modes to safe OpenCode permission rules' fails with the fix stashed (expected undefined to equal 'allow'). vp run check:changed: format, lint, knip, typecheck (10 packages) and tests (2 files) all pass. Manual run against a real opencode serve 1.19.5 (scratch driver, not committed): the bug reproduced with the old rules and was gone with the new ones.
Not in this change#
- The post-creation session.update of child rules in adapter.ts (~1406) still cannot affect an already-running child. It remains useful for later runs and policy changes, so I left it.
- In supervised modes children still inherit only the deny rules plus OpenCode's agent defaults until the update lands. That is the existing behaviour and is not part of this report.
AI-assisted; verified with the tests and tools listed above.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅ Codex Live turn messages 1 1 0 (0.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅ Claude Live turn messages 1 1 0 (0.0%) 8 ✅ Other scenarios#
All 64 scenario measurements match
main.All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling Codex short turn resumeWebSocket decoded10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅ Codex short turn resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Codex long turn running, cold openHTTP decoded281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅ Codex long turn running, cold openrows75 75 0 (0.0%) 75 ✅ Codex long turn running, history pageHTTP decoded92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅ Codex long turn running, history pagerows75 75 0 (0.0%) 75 ✅ Codex long turn finished, cold openHTTP decoded381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅ Codex long turn finished, cold openrows151 151 0 (0.0%) 151 ✅ Codex long turn finished, socket cold openWebSocket decoded381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅ Codex long turn finished, socket cold openWebSocket messages2 2 0 (0.0%) 2 ✅ Codex long turn finished, socket cold openrows151 151 0 (0.0%) 151 ✅ Codex long turn finished, work pageHTTP decoded186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅ Codex long turn finished, work pagerows150 150 0 (0.0%) 150 ✅ Codex idle thread resumeWebSocket decoded65 B 65 B 0 B (0.0%) 200 B ✅ Codex idle thread resumeWebSocket messages1 1 0 (0.0%) 1 ✅ Codex fleet shell snapshotHTTP decoded41.6 KiB 41.6 KiB 0 B (0.0%) 53.7 KiB ✅ Codex fleet shell snapshotrows27 27 0 (0.0%) 27 ✅ Codex fleet shell subscribeWebSocket decoded65 B 65 B 0 B (0.0%) 200 B ✅ Codex fleet shell subscribeWebSocket messages1 1 0 (0.0%) 1 ✅ Codex fleet shell resume checkHTTP decoded18 B 18 B 0 B (0.0%) 100 B ✅ Codex fleet shell resume checkrows0 0 0 0 ✅ Codex stale shell reloadHTTP decoded41.6 KiB 41.6 KiB 0 B (0.0%) 53.7 KiB ✅ Codex stale shell reloadrows27 27 0 (0.0%) 27 ✅ Codex stale shell resumeWebSocket decoded140 B 140 B 0 B (0.0%) 400 B ✅ Codex stale shell resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Codex stale todo list cold openHTTP decoded72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅ Codex stale todo list cold openrows75 75 0 (0.0%) 75 ✅ Codex stale todo list cold opennodes2 2 0 (0.0%) 4 ✅ Codex stale todo list cold opensubagents2 2 0 (0.0%) 4 ✅ Codex stale todo list cold openplans1 1 0 (0.0%) 2 ✅ Codex stale todo list cold openproviderTurns1 1 0 (0.0%) 2 ✅ Codex stale todo list cold opencheckpoints1 1 0 (0.0%) 2 ✅ Claude short turn resumeWebSocket decoded10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅ Claude short turn resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Claude long turn running, cold openHTTP decoded283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅ Claude long turn running, cold openrows75 75 0 (0.0%) 75 ✅ Claude long turn running, history pageHTTP decoded93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅ Claude long turn running, history pagerows75 75 0 (0.0%) 75 ✅ Claude long turn finished, cold openHTTP decoded384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅ Claude long turn finished, cold openrows151 151 0 (0.0%) 151 ✅ Claude long turn finished, socket cold openWebSocket decoded384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅ Claude long turn finished, socket cold openWebSocket messages2 2 0 (0.0%) 2 ✅ Claude long turn finished, socket cold openrows151 151 0 (0.0%) 151 ✅ Claude long turn finished, work pageHTTP decoded188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅ Claude long turn finished, work pagerows150 150 0 (0.0%) 150 ✅ Claude idle thread resumeWebSocket decoded66 B 66 B 0 B (0.0%) 200 B ✅ Claude idle thread resumeWebSocket messages1 1 0 (0.0%) 1 ✅ Claude fleet shell snapshotHTTP decoded42.2 KiB 42.2 KiB 0 B (0.0%) 53.7 KiB ✅ Claude fleet shell snapshotrows27 27 0 (0.0%) 27 ✅ Claude fleet shell subscribeWebSocket decoded66 B 66 B 0 B (0.0%) 200 B ✅ Claude fleet shell subscribeWebSocket messages1 1 0 (0.0%) 1 ✅ Claude fleet shell resume checkHTTP decoded18 B 18 B 0 B (0.0%) 100 B ✅ Claude fleet shell resume checkrows0 0 0 0 ✅ Claude stale shell reloadHTTP decoded42.2 KiB 42.2 KiB 0 B (0.0%) 53.7 KiB ✅ Claude stale shell reloadrows27 27 0 (0.0%) 27 ✅ Claude stale shell resumeWebSocket decoded140 B 140 B 0 B (0.0%) 400 B ✅ Claude stale shell resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Claude stale todo list cold openHTTP decoded73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅ Claude stale todo list cold openrows75 75 0 (0.0%) 75 ✅ Claude stale todo list cold opennodes2 2 0 (0.0%) 4 ✅ Claude stale todo list cold opensubagents2 2 0 (0.0%) 4 ✅ Claude stale todo list cold openplans1 1 0 (0.0%) 2 ✅ Claude stale todo list cold openproviderTurns1 1 0 (0.0%) 2 ✅ Claude stale todo list cold opencheckpoints1 1 0 (0.0%) 2 ✅ Baseline:
a5bd0ba· PR result:f4816f9· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
Walkthrough
-
When approvals are disabled in the full-access path, OpenCode permission rules now include an explicit
external_directoryallow rule alongside the wildcard allow rule. A test checks that external directories remain allowed.Changes: OpenCode full-access permissions
Layer / File(s) Summary Full-access permission rule
packages/provider-opencode/src/server/adapter.ts,packages/provider-opencode/src/server/adapter.test.tsThe no-approval full-access path adds an external_directoryallow rule for every pattern. The test checks that filtering the rules still leavesexternal_directoryallowed.Estimated code review effort: 2 (Simple) | ~5 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related PRs
- pingdotgg/t3code#26302: Changes child permission-rule derivation and updates child sessions when their computed rules change.
Suggested reviewers:
macroscopeapp,saphid
Merge Risk:
Minimal · up tof4816-
Full access subagents on the targeted OpenCode version should no longer prompt for outside-directory access, and the parent's behavior is unchanged. Older OpenCode versions may still prompt, but that behavior is not made worse by this change. The change looks safe to merge.
Pre-merge checks:
3 · 1-
Failed checks: 1 inconclusiveCheck name Status Explanation Resolution Linked Issues check Issue #35246requires that OpenCode 1.x subagents in Full access stop prompting for approval, includingexternal_directory. The change addsexternal_directory * allowtoopenCodePermissionRules…Provide evidence that a Full access @generalor@explorechild run on OpenCode 1.19.x does not prompt for shell commands such asgrep,sed, orgit diffafter this change. A reproduction run with the new rules, or an explicit scope… Passed checks: 3 passed-
Check name Status Explanation Title check The title names the OpenCode Full access fix and the symptom it removes, which matches the main change: adding an explicit external_directory allow rule so subagents do not prompt. It is specific and … Out of Scope Changes check The change touches openCodePermissionRulesinpackages/provider-opencode/src/server/adapter.tsand its test inadapter.test.ts. It applies only when approvals are disabled and the sandbox is `ex…Description check The description covers the template sections. Problem: OpenCode 1.19.5 child sessions created by the task tool miss parent allow rules, so Full access subagents prompt for external_directory approval.… Full details: Title check
-
Explanation
The title names the OpenCode Full access fix and the symptom it removes, which matches the main change: adding an explicit external_directory allow rule so subagents do not prompt. It is specific and conventional-commit formatted. The wording is slightly long at 67 characters, but it is accurate.
Full details: Out of Scope Changes check
-
Explanation
The change touches
openCodePermissionRulesinpackages/provider-opencode/src/server/adapter.tsand its test inadapter.test.ts. It applies only when approvals are disabled and the sandbox isexternalSandbox,dangerFullAccess, or implicit full access. Supervised modes keep their existing rules. The PR description states that parent behavior is otherwise unchanged. The test change and the rule change both serve#35246. No unrelated changes were identified in the summary.
Full details: Description check
-
Explanation
The description covers the template sections. Problem: OpenCode 1.19.5 child sessions created by the task tool miss parent allow rules, so Full access subagents prompt for external_directory approval. Change: openCodePermissionRules adds an explicit external_directory allow rule in Full access, so the child copies it at creation. Scope: it links issue
#35246as the bug report and states the change is a bug fix with no feature added. Verification: it gives a reproduction on main, before/after evidence with screenshots and recordings, a real opencode serve 1.19.5 run, and test results (54 passed, new assertion fails with the fix stashed). It also lists what was not exercised (@explore, desktop, mobile, other OpenCode versions) and what is out of scope. It ends with the AI-assisted note, but the template asks for the model and harness used; the description says 'AI-assisted' without naming the model or harness, so that line is only partly complete. Overall the description is mostly complete.
-
Full details: Linked Issues check
-
Explanation
Issue
#35246requires that OpenCode 1.x subagents in Full access stop prompting for approval, includingexternal_directory. The change addsexternal_directory * allowtoopenCodePermissionRulesfor Full access, so the child copies that rule at creation. The author reports a manual run againstopencode serve1.19.5. With the new rules, the@generalchild rancaton an outside path with no permission request. The unit assertion inmaps runtime modes to safe OpenCode permission rulesfails when the fix is stashed. This covers theexternal_directoryrequirement. The issue also lists prompts for shell commands (grep,sed,git diff) in subagents. The PR does not show whether those prompts still occur after the change. The copy logic inagent/subagent-permissions.tscopies only deny andexternal_directoryrules. The PR does not verify non-external_directorychild prompts, so that part of the requirement is not established. The post-creationsession.updatealso remains unable to affect a running child, as the PR states.Resolution
Provide evidence that a Full access
@generalor@explorechild run on OpenCode 1.19.x does not prompt for shell commands such asgrep,sed, orgit diffafter this change. A reproduction run with the new rules, or an explicit scope decision that limits#35246toexternal_directory, would resolve this.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
Additional comments: 1-
packages/provider-opencode/src/server/adapter.ts-617-620: 1
-
617-620: Major · Functional Correctness · Heavy lift **Unverified finding** Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.Handle task children on supported older OpenCode versions.
OpenCodeRuntime.MINIMUM_OPENCODE_VERSIONis1.14.19, but OpenCode 1.14.19 creates task children without copying the parent’s permission rules. Its default subagent policy asks for external-directory access, so the first tool call can still prompt before the child update. (raw.githubusercontent.com)Provide a fallback for versions without inheritance, or require a version that supports it. Cover the supported version boundary.
-
Review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: factory/issue-35246
- File: .coderabbit.config.ts
- Commit: f4816f9
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
34562d9d-bbef-4dbf-b951-8960033af9c7
Commits-
Reviewing files that changed from the base of the PR and between a5bd0ba5265fdfbfadc9149a54300b5048f853cb and f4816f9a9515e1f5f863781ae13e5db32e755d97.
Files selected for processing: 2-
packages/provider-opencode/src/server/adapter.test.tspackages/provider-opencode/src/server/adapter.ts
Limit details: You’ve used all 10 included reviews currently available.
-
-
tanstack-source added labelsbug
maria-rcks merged this166cb00
maria-rcks closed this
Sign in to join this conversation.




Approvability#
Verdict: Needs Human Approval
Macroscope's review found this PR requires human approval — Subagents will inherit outside-directory access immediately rather than prompting in Full access sessions. This changes their effective default permission behavior, requiring human confirmation even though it aligns with the parent policy.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).