Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(opencode): Full access subagents start without approval prompts #35401

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/35401/headmerged by maria-rcks View on GitHub

juliusmarmingecommented

OpenCode 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.

BeforeAfter
4e48d9e6a5f4816f9a95
Before: subagent waits for approvalAfter: both command outputs returned
Before: Full access selectedAfter: Full access selected
Before recordingAfter 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

    2. 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).
    3. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.5 KiB21.5 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages110 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Other scenarios

      All 64 scenario measurements match main.

      All 64 scenario measurements
      ProviderScenarioMetricMain baselineThis PRImpactPR ceiling
      Codexshort turn resumeWebSocket decoded10.5 KiB10.5 KiB0 B (0.0%)12.7 KiB✅
      Codexshort turn resumeWebSocket messages220 (0.0%)2✅
      Codexlong turn running, cold openHTTP decoded281.7 KiB281.7 KiB0 B (0.0%)302.7 KiB✅
      Codexlong turn running, cold openrows75750 (0.0%)75✅
      Codexlong turn running, history pageHTTP decoded92.4 KiB92.4 KiB0 B (0.0%)107.4 KiB✅
      Codexlong turn running, history pagerows75750 (0.0%)75✅
      Codexlong turn finished, cold openHTTP decoded381.5 KiB381.5 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, socket cold openWebSocket decoded381.6 KiB381.6 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Codexlong turn finished, socket cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, work pageHTTP decoded186.2 KiB186.2 KiB0 B (0.0%)200.2 KiB✅
      Codexlong turn finished, work pagerows1501500 (0.0%)150✅
      Codexidle thread resumeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexidle thread resumeWebSocket messages110 (0.0%)1✅
      Codexfleet shell snapshotHTTP decoded41.6 KiB41.6 KiB0 B (0.0%)53.7 KiB✅
      Codexfleet shell snapshotrows27270 (0.0%)27✅
      Codexfleet shell subscribeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexfleet shell subscribeWebSocket messages110 (0.0%)1✅
      Codexfleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Codexfleet shell resume checkrows0000✅
      Codexstale shell reloadHTTP decoded41.6 KiB41.6 KiB0 B (0.0%)53.7 KiB✅
      Codexstale shell reloadrows27270 (0.0%)27✅
      Codexstale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Codexstale shell resumeWebSocket messages220 (0.0%)2✅
      Codexstale todo list cold openHTTP decoded72.4 KiB72.4 KiB0 B (0.0%)83.0 KiB✅
      Codexstale todo list cold openrows75750 (0.0%)75✅
      Codexstale todo list cold opennodes220 (0.0%)4✅
      Codexstale todo list cold opensubagents220 (0.0%)4✅
      Codexstale todo list cold openplans110 (0.0%)2✅
      Codexstale todo list cold openproviderTurns110 (0.0%)2✅
      Codexstale todo list cold opencheckpoints110 (0.0%)2✅
      Claudeshort turn resumeWebSocket decoded10.6 KiB10.6 KiB0 B (0.0%)12.7 KiB✅
      Claudeshort turn resumeWebSocket messages220 (0.0%)2✅
      Claudelong turn running, cold openHTTP decoded283.3 KiB283.3 KiB0 B (0.0%)302.7 KiB✅
      Claudelong turn running, cold openrows75750 (0.0%)75✅
      Claudelong turn running, history pageHTTP decoded93.4 KiB93.4 KiB0 B (0.0%)107.4 KiB✅
      Claudelong turn running, history pagerows75750 (0.0%)75✅
      Claudelong turn finished, cold openHTTP decoded384.2 KiB384.2 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, socket cold openWebSocket decoded384.3 KiB384.3 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Claudelong turn finished, socket cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, work pageHTTP decoded188.1 KiB188.1 KiB0 B (0.0%)200.2 KiB✅
      Claudelong turn finished, work pagerows1501500 (0.0%)150✅
      Claudeidle thread resumeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudeidle thread resumeWebSocket messages110 (0.0%)1✅
      Claudefleet shell snapshotHTTP decoded42.2 KiB42.2 KiB0 B (0.0%)53.7 KiB✅
      Claudefleet shell snapshotrows27270 (0.0%)27✅
      Claudefleet shell subscribeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudefleet shell subscribeWebSocket messages110 (0.0%)1✅
      Claudefleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Claudefleet shell resume checkrows0000✅
      Claudestale shell reloadHTTP decoded42.2 KiB42.2 KiB0 B (0.0%)53.7 KiB✅
      Claudestale shell reloadrows27270 (0.0%)27✅
      Claudestale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Claudestale shell resumeWebSocket messages220 (0.0%)2✅
      Claudestale todo list cold openHTTP decoded73.4 KiB73.4 KiB0 B (0.0%)83.0 KiB✅
      Claudestale todo list cold openrows75750 (0.0%)75✅
      Claudestale todo list cold opennodes220 (0.0%)4✅
      Claudestale todo list cold opensubagents220 (0.0%)4✅
      Claudestale todo list cold openplans110 (0.0%)2✅
      Claudestale todo list cold openproviderTurns110 (0.0%)2✅
      Claudestale todo list cold opencheckpoints110 (0.0%)2✅

      Baseline: a5bd0ba · PR result: f4816f9 · Source CI: success

      Scenario 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.

    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →
      Walkthrough

      When approvals are disabled in the full-access path, OpenCode permission rules now include an explicit external_directory allow 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.ts
      The no-approval full-access path adds an external_directory allow rule for every pattern. The test checks that filtering the rules still leaves external_directory allowed.

      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 to f4816

      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: Passed 3 · Inconclusive 1

      Failed Failed checks: 1 inconclusive
      Check nameStatusExplanationResolution
      Linked Issues checkInconclusiveIssue #35246 requires that OpenCode 1.x subagents in Full access stop prompting for approval, including external_directory. The change adds external_directory * allow to openCodePermissionRules …Provide evidence that a Full access @general or @explore child run on OpenCode 1.19.x does not prompt for shell commands such as grep, sed, or git diff after this change. A reproduction run with the new rules, or an explicit scope…
      Passed Passed checks: 3 passed

      Check nameStatusExplanation
      Title checkPassedThe 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 checkPassedThe change touches openCodePermissionRules in packages/provider-opencode/src/server/adapter.ts and its test in adapter.test.ts. It applies only when approvals are disabled and the sandbox is `ex…
      Description checkPassedThe 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 openCodePermissionRules in packages/provider-opencode/src/server/adapter.ts and its test in adapter.test.ts. It applies only when approvals are disabled and the sandbox is externalSandbox, 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 #35246 as 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 #35246 requires that OpenCode 1.x subagents in Full access stop prompting for approval, including external_directory. The change adds external_directory * allow to openCodePermissionRules for Full access, so the child copies that rule at creation. The author reports a manual run against opencode serve 1.19.5. With the new rules, the @general child ran cat on an outside path with no permission request. The unit assertion in maps runtime modes to safe OpenCode permission rules fails when the fix is stashed. This covers the external_directory requirement. 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 in agent/subagent-permissions.ts copies only deny and external_directory rules. The PR does not verify non-external_directory child prompts, so that part of the requirement is not established. The post-creation session.update also remains unable to affect a running child, as the PR states.

      Resolution

      Provide evidence that a Full access @general or @explore child run on OpenCode 1.19.x does not prompt for shell commands such as grep, sed, or git diff after this change. A reproduction run with the new rules, or an explicit scope decision that limits #35246 to external_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
    5. 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_VERSION is 1.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

      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.ts
      • packages/provider-opencode/src/server/adapter.ts

      Limit details: You’ve used all 10 included reviews currently available.

    6. tanstack-source added labelsbug

    7. maria-rcks merged this166cb00

    8. maria-rcks closed this

Sign in to join this conversation.