Scheduled automations cannot access GitHub API in default sandbox despite allowlisted gh api and loaded token
Resolved 💬 6 comments Opened Feb 26, 2026 by codingscape-jay Closed Jun 22, 2026
What version of the Codex App are you using (From “About Codex” dialog)?
Version 26.224.1209 (697)
What subscription do you have?
Plus
What platform is your computer?
macOS arm
What issue are you seeing?
Summary
Scheduled automation runs appear to enforce network denial regardless of .env token loading and default.rules allowlists. The same commands succeed only when execution is elevated/unrestricted.
Impact
GitHub-dependent scheduled automations (PR review/reporting workflows) are non-functional in default scheduled runtime.
Suspected cause
Scheduler/runtime policy mismatch:
- allowlist rules and env loading are present
- but network egress remains blocked in default scheduled execution.
What steps can reproduce the bug?
- Configure:
~/.codex/.envwithGH_TOKEN,GITHUB_TOKEN,GH_HOST=github.com~/.codex/rules/default.ruleswith:prefix_rule(pattern=["gh","api"], decision="allow")
- Run scheduled automation (default permissions) with:
echo "CODEX_SANDBOX_NETWORK_DISABLED=$CODEX_SANDBOX_NETWORK_DISABLED"[ -n "$GH_TOKEN" ] && echo "GH_TOKEN=set" || echo "GH_TOKEN=missing"gh api /user --jq '.login'
- Observe API failure.
- In same run:
source ~/.codex/.envgh api /user --jq '.login'
- Observe API still fails.
- Re-run same commands under elevated/unrestricted execution.
- Observe API succeeds.
What is the expected behavior?
Per docs, automations run with default sandbox settings and allowlisted commands can run outside sandbox.
Given:
prefix_rule(pattern=["gh","api"], decision="allow")GH_TOKENprovided via~/.codex/.env
The automation should be able to execute gh api /user successfully.
Additional information
Actual behavior
In scheduled/default context:
CODEX_SANDBOX_NETWORK_DISABLED=1GH_TOKEN=missinggh api /user --jq '.login'fails with:error connecting to api.github.comcheck your internet connection or https://githubstatus.com
Even after explicitly sourcing env in-shell:
source ~/.codex/.envGH_TOKEN=setCODEX_SANDBOX_NETWORK_DISABLED=0(shell var)gh api /userstill fails with the same connectivity error
In elevated/unrestricted context, the exact same gh commands succeed.
6 Comments
Additional confirmed repro + root-cause signal from today (2026-02-27, macOS 26.3, Codex desktop 26.226.940, CLI 0.105.0).
I forced an immediate run of automation
eudorus-control-towerand captured both automation and host-shell evidence:019ca111-20ba-7a23-af42-9dd0b48156afPENDING_REVIEWwith inbox titleGitHub preflight now network-blockedgh api user --jq .login->louspringerGIT_TERMINAL_PROMPT=0 git ls-remote https://github.com/energration/eudorus.git HEAD-> HEAD resolves"network_access":false:threads.id=019ca111-20ba-7a23-af42-9dd0b48156afsandbox_policy={...,"network_access":false,...}This strongly indicates automation runtime policy is forcing network off (or misapplying policy) even when host session has healthy GitHub connectivity and auth.
If useful, I also added a deterministic preflight script in the automation (
gh auth status,gh api user,git ls-remote) specifically to avoid false token-vs-DNS attribution.I can reproduce this in Codex Desktop on macOS, and I have stronger local evidence that the failure is caused by the automation runner starting with a different sandbox/network policy than an interactive chat session.
What I verified just now:
gh auth statusshows I am logged intogithub.comwith a valid token (reposcope present).gh api repos/mangerlahn/Latest --jq '{full_name, default_branch, open_issues_count}'succeeds.What the scheduled automation runs show:
Watch Latest Upstream.execution_environment = "worktree"in~/.codex/automations/watch-latest-upstream/automation.toml.sandbox_mode=workspace-writeNetwork access is restrictedcurl: (6) Could not resolve host: api.github.comcurl: (6) Could not resolve host: github.comAffected rollout files on my machine:
rollout-2026-03-16T14-36-01-019cf6dc-59bd-7480-adfc-79b51ec59331.jsonlrollout-2026-03-16T15-36-20-019cf713-91fa-79a2-b3a4-53783dec93a8.jsonlrollout-2026-03-16T17-36-23-019cf781-7974-7a50-8d83-d52648551db0.jsonlImportant distinction:
ghtoken missing” or “GitHub API flaky”.ghworks immediately.So the bug appears to be:
workspace-write+ network-disabled policy regardless of live app capabilities/configImpact:
gh.If useful, I can attach sanitized excerpts from the rollout JSONL showing:
Network access is restrictedapi.github.comgh apioutside the scheduled automation rolloutI investigated this locally and have a concrete root-cause hypothesis plus a small fix.
Root cause hypothesis
Trusted execpolicy matches already get classified as
ExecApprovalRequirement::Skip { bypass_sandbox: true, .. }, but the first exec attempt only converts that intoSandboxType::None.The same first attempt still inherits the turn's
network_sandbox_policy, so in scheduled/default runs an allowlisted command likegh apiis launched without network access even though execpolicy marked it as trusted.That matches the report here:
gh apiProposed fix
Treat trusted execpolicy skips differently from ordinary explicit escalation:
with_escalated_permissionsbehavior unchanged except for sandbox bypassSkip { bypass_sandbox: true }, bypass the first-attempt sandbox and forceNetworkSandboxPolicy::EnabledIn practice this is a small orchestrator change:
Validation
I tested this locally with targeted unit coverage for:
I also ran:
just fmtcargo test -p codex-coreThe new tests passed. In my environment,
cargo test -p codex-corestill has three unrelated existing failures:seatbelt::tests::create_seatbelt_args_with_read_only_git_pointer_fileseatbelt::tests::create_seatbelt_args_with_read_only_git_and_codex_subpathsshell_snapshot::tests::snapshot_shell_does_not_inherit_stdinIf helpful, I have the patch prepared on my fork and can open it if a maintainer wants a PR.
+1
Please fix this. I have codex designing it's own automations using CURL right now - they will fail.
This is a classic browser-auth vs runtime-auth style mismatch, except here it is scheduler policy vs shell policy. The useful receipt would be explicit at automation start: env loaded yes or no, network egress allowed yes or no, allowlist rule matched yes or no, and which layer denied the call. Right now users do the detective work after the failure. That kind of preflight receipt is exactly what keeps automation loops from burning time on impossible work.