Repository navigation
fix(executor): Codex honours tool_policy (read-only sandbox, refuse what it cannot express) - #2624
Merged
Merged
Conversation
…hat it cannot express) The Codex exec path never read Task.AllowedTools and always launched with --dangerously-bypass-approvals-and-sandbox, so question tasks and restricted tool_policy agents ran with a full shell. The daemon adapter refused every allowlist outright. resolveCodexPermissions (permissions.go) now decides for both paths: - nil: unchanged full access (bypass flag / danger-full-access) - only read-only names: --sandbox read-only, approval_policy "never", no bypass; WebFetch/WebSearch enable the hosted web_search, else disabled - any write/shell tool, or an empty list: refused, naming the tools The daemon's thread/start carries the same sandbox and approval policy. Result.ToolPolicy banks the sandbox each run used. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The Codex executor now applies
Task.AllowedTools(the coordinator's resolvedtool_policy) instead of always launching with--dangerously-bypass-approvals-and-sandbox. Before this, the exec path never readAllowedTools, so a question task (always given a read-only list) or an agent with a restrictedtool_policyran on Codex with an unrestricted shell. The daemon adapter refused every allowlist outright.One function,
resolveCodexPermissionsininternal/executor/codex/permissions.go, now makes the decision for both launch paths:AllowedToolsthread/startnil(full / no policy)--dangerously-bypass-approvals-and-sandbox(unchanged)sandbox: danger-full-access,approvalPolicy: never(unchanged)--sandbox read-only -c approval_policy="never" -c web_search="live"|"disabled", no bypasssandbox: read-only,approvalPolicy: never,config.web_search[]web_searchis a hosted tool that runs on the provider's side, not in the local sandbox, so it works underread-onlywhile the shell keeps no network. It islivewhen the list has WebFetch or WebSearch (Codex has no separate fetch tool;livecan open pages), anddisabledotherwise. Question tasks therefore keep web search.workspace-writemapping. It is not an exact match: without Bash it would give the agent a shell that can write; with Bash it is narrower than Bash elsewhere (writes only under the workspace, no network). Refusing is what the daemon adapter, motoko and pi already do.ailang_onlyagent,question ∩ ailang_only = []) is refused. Codex always has a shell, so it cannot run with no tools.approval_policy="never"rejects escalation requests).Result.ToolPolicynow records the sandbox each Codex run used:<cli default>, or e.g.sandbox:read-only, approval:never, web_search:live. Before, it was nil (unmeasured).Task.MCPServers(eval browser benchmarks only) are unchanged. The caller grants them explicitly.Flags verified against the installed CLI (codex-cli 0.173.0), no model call
codex exec --helplists-s, --sandbox <read-only|workspace-write|danger-full-access>.exechas no-a, so the approval policy is passed with-c approval_policy=....CODEX_HOME,codex debug prompt-input -c web_search="bogus"(and the same forsandbox_modeandapproval_policy) fails withunknown variant. Each error lists the accepted values (disabled|cached|indexed|live,read-only|...,never|...), which shows all three keys exist and are validated. With the read-only settings, the rendered model prompt says: "sandbox_modeisread-only: The sandbox only permits reading files. Network access is restricted."codex exec. It parsed and reachedturn.started, then failed with 401 because there was no auth, so nothing was spent.codex sandbox -P :read-only -- sh -c '...': the read succeeded, the write failed withOperation not permitted, andcurlfailed withCould not resolve host.Launch sites (
grep -rn dangerously-bypass internal/ cmd/)internal/executor/codex/mcp_config.gobuildCodexArgs(exec and streaming): now goes throughresolveCodexPermissions.internal/executor/codex/daemon_execution.go: the blanket refusal is replaced with the same decision.thread/startalready carriessandboxandapprovalPolicy, andweb_searchrides in itsconfig.ExecuteStreamingresolves before either runtime branch, soAILANG_CODEX_RUNTIME=daemonandclirefuse identically.coordinator_cloud_executor.go) and the eval harness reach Codex through the same executor.cmd/ailang/mission_codex_exec.go(mission CLI, defaults toread-only; the bypass is an explicit operator flag),internal/mission/quorum/codex_reviewer.go(alwaysread-only), andinternal/mission/codex_app_server_quota.go(quota probe). There is no separate codex-agy twin: agy is its own executor.Live-lane impact
The coordinator config (
ailang-multivacconfig/config.cloud.yaml) has two Codex agents,sprint-planner(codex) andsprint-executor(codex-go). Neither setstool_policy, so their normal tasks are unchanged (full). Question-kind tasks routed to them now run read-only with web search instead of with full access. No Codex agent declarestool_policy. The local~/.ailang/config.yamlhas no Codex agents.Agents that will now refuse to start
None in the coordinator agent config. Code paths that would now refuse on Codex:
internal/mission/dispatch/run.go,AllowedTools = [Read, Bash]): refused, naming Bash. On the rig'sAILANG_CODEX_RUNTIME=daemonthis path was already refused by the old daemon check, so only acli-runtime Codex evaluator changes. To run one, route the evaluator to claude or pi, or drop its allowlist (not recommended).tool_policy: ailang_onlyorleanon Codex: refused, naming the write and shell tools. Fix: useprovider: pifor those lanes, or cleartool_policy.Tests
internal/executor/codex/permissions_test.go:TestBuildCodexArgs_NilToolPolicyKeepsBypass: nil keeps the exact byte-compatible argv.TestBuildCodexArgs_QuestionToolsRunReadOnly: the exact read-only argv, with no bypass.TestBuildCodexArgs_ReadOnlyWithoutWebDisablesSearchTestBuildCodexArgs_RefusesWhatReadOnlyCannotExpress:ailang_only,lean, mission evaluator, a write tool, and the empty list. Each asserts the daemon gives the identical error.TestDaemonExecOptions_SharesTheExecDecisionTestDaemonProtocolSendsReadOnlySandbox:thread/starton the wire carriesread-only,neverandweb_search.TestExecuteStreamingHonoursToolPolicy: a fake codex records its argv. A question task runs read-only and banks itsToolPolicy. A shell-tool task is refused and codex never launches, under both theclianddaemonruntimes.Mutation-tested with scratch copies. All five mutants failed the suite: always bypass, never refuse, daemon hardcoded to full access, web search always off, and empty list allowed.
Gates:
make test-changed,make lint,make check-file-sizes,make check-boundaries,make check-changelog.🤖 Generated with Claude Code