[Bug]: OpenCode session rules force constant shell prompting in Auto mode, while Full Access breaks Codex (approvalPolicy: "never") #17395
Summary#
There is an architectural conflict between how T3 Code maps runtime permission modes for OpenCode v2 versus other providers (specifically Codex):
- In
OpenCode2AdapterV2.ts, any thread in non-full-accessmode (includingauto,auto-accept-edits, andapproval-required) blanket injectsrule("shell", "ask")into OpenCode's session permissions viaclient.session.update(). In OpenCode v2, session-level rules take precedence over local config (~/.config/opencode/opencode.json), causing OpenCode to emitpermission.askedand prompt the user in the UI for every shell command (including routine read-only commands likegit statusorls). - When users switch to Full access to avoid this constant prompting,
CodexSessionRuntime.tsmapsfull-accessdirectly toapprovalPolicy: "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-accessmodes,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
automode is treated identically toapproval-required, clobbering the user'sopencode.jsonallowlist.
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 receivesapprovalPolicy: "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
--automode, or - Defer to the user's configured
~/.config/opencode/opencode.jsonpermissions instead of overriding with a blanket{ action: "shell", resource: "*", effect: "ask" }.
- Run with OpenCode's native
- 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#
- OpenCode Adapter: Update
sessionRulesinOpenCode2AdapterV2.tsso that inautomode it either omits the wildcard shell ask rule (letting OpenCode resolve via its config allowlist) or passes--autoto the OpenCode server session. - Per-Provider Defaults: Allow configuring default runtime modes per provider under Settings → Providers rather than enforcing a single global mode across different provider engines.
juliusmarminge added labelsduplicate
juliusmarminge closed this
Sign in to join this conversation.
Note
Grok responding on behalf of Julius.
Closing as a duplicate of the two open reports this combines:
shell/askrules that override~/.config/opencodepermissions → #11458approvalPolicy: "never"so policy-prompted commands abort instead of asking → #12248Please continue on those threads (per-provider runtime defaults would also belong on them).