Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: OpenCode session rules force constant shell prompting in Auto mode, while Full Access breaks Codex (approvalPolicy: "never") #17395

Closedseankoji(GitHub profile, opens in a new tab) opened this issue 1 comment

Summary

There is an architectural conflict between how T3 Code maps runtime permission modes for OpenCode v2 versus other providers (specifically Codex):

  1. In OpenCode2AdapterV2.ts, any thread in non-full-access mode (including auto, auto-accept-edits, and approval-required) blanket injects rule("shell", "ask") into OpenCode's session permissions via client.session.update(). In OpenCode v2, session-level rules take precedence over local config (~/.config/opencode/opencode.json), causing OpenCode to emit permission.asked and prompt the user in the UI for every shell command (including routine read-only commands like git status or ls).
  2. When users switch to Full access to avoid this constant prompting, CodexSessionRuntime.ts maps full-access directly to approvalPolicy: "never". In Codex CLI / API, "never" means headless / non-interactive execution where prompting is strictly forbidden. Any command or tool requiring confirmation immediately fails and aborts the turn instead of prompting the user.

As a result, users cannot run OpenCode without constant prompts unless they set Full Access, but setting Full Access breaks Codex threads and turns.


Code Analysis & Root Causes

1. OpenCode Session Rules in OpenCode2AdapterV2.ts

In OpenCode2AdapterV2.ts:

sessionRules = (policy, paths, grants, mcpServerName) => [
  ...(policy.runtimeMode === "full-access"
    ? [rule("*", "allow")]
    : [
        rule("shell", "ask"),
        rule("edit", policy.runtimeMode === "auto-accept-edits" ? "allow" : "ask"),
        rule("external_directory", "ask"),
      ]),
  ...grants,
  ...paths,
  ...mcpRules(mcpServerName),
];
  • For non-full-access modes, rule("shell", "ask") sets { action: "shell", resource: "*", effect: "ask" } on the session.
  • Unlike other providers that have built-in review or selective allowlists, OpenCode in auto mode is treated identically to approval-required, clobbering the user's opencode.json allowlist.

2. Codex Approval Policy in CodexSessionRuntime.ts / turn defaults

In codexRuntimeModeTurnDefaults:

function codexRuntimeModeTurnDefaults(runtimeMode) {
  switch (runtimeMode) {
    case "auto":
      return {
        approvalPolicy: "on-request",
        approvalsReviewer: "auto_review",
        sandboxPolicy: { type: "workspaceWrite" },
      };
    case "full-access":
      return {
        approvalPolicy: "never",
        approvalsReviewer: "user",
        sandboxPolicy: { type: "dangerFullAccess" },
      };
  }
}
  • In full-access, Codex receives approvalPolicy: "never".
  • When Codex requires approval (e.g. out-of-sandbox actions, untrusted project access, sensitive commands), rather than bubbling up an interactive approval request to T3 Code, Codex enforces "never" by refusing to prompt and aborting the turn.

Expected Behavior

  • In Auto mode, OpenCode should either:
    • Run with OpenCode's native --auto mode, or
    • Defer to the user's configured ~/.config/opencode/opencode.json permissions instead of overriding with a blanket { action: "shell", resource: "*", effect: "ask" }.
  • In Full access mode, Codex should not fail when an authorization prompt is triggered, or permission policies should be decouplable per provider in Settings.

Suggested Fixes

  1. OpenCode Adapter: Update sessionRules in OpenCode2AdapterV2.ts so that in auto mode it either omits the wildcard shell ask rule (letting OpenCode resolve via its config allowlist) or passes --auto to the OpenCode server session.
  2. Per-Provider Defaults: Allow configuring default runtime modes per provider under Settings → Providers rather than enforcing a single global mode across different provider engines.
  1. Note

    Grok responding on behalf of Julius.

    Closing as a duplicate of the two open reports this combines:

    • OpenCode Auto injecting session shell/ask rules that override ~/.config/opencode permissions → #11458
    • Codex Full access mapping to approvalPolicy: "never" so policy-prompted commands abort instead of asking → #12248

    Please continue on those threads (per-provider runtime defaults would also belong on them).

  2. juliusmarminge added labelsduplicate

  3. juliusmarminge closed this

Sign in to join this conversation.