Drive Codex's own scripted execution mode through the Azure AI Foundry passthrough, giving a resumed or fresh session one instruction without a terminal UI.
pks codex exec [ARGS] [options]$ pks codex exec resume --last "Continue the previous task"Resume the last session and give it a new instruction
Run Codex without its interactive interface. pks codex exec forwards Codex's own non-interactive execution mode through the loopback passthrough, so a scripted instruction runs against an Azure AI Foundry deployment with Entra authentication supplied per request.
pks foundry init, with a resource endpoint selected.npm i -g @openai/codex.codex exec. The argument grammar after exec belongs to the Codex CLI, not to pks.pks codex exec resume --last "Continue the previous task"
pks starts the passthrough, forwards resume --last "Continue the previous task" to codex exec untouched, and streams whatever Codex produces.
Nested native subcommands and flags survive because pks recovers them from the raw process arguments rather than from parsed remaining arguments.
pks codex exec --model gpt-5-codex --reasoning-effort high resume --last "Run the test suite and fix failures"
Pinning the deployment keeps a scheduled or scripted run from drifting when the Foundry account default changes.
An unattended run bypasses Codex's approval prompts by default, which is the point of running it unattended — pks appends --dangerously-bypass-approvals-and-sandbox unless told otherwise. Add --safe when the run happens on a machine that is not disposable.
pks codex exec --safe resume --last "Summarize what changed"
pks codex --print-env
The printed launch command shows the resolved deployment and loopback port that an exec run will use. Stop the foreground passthrough with Ctrl-C.
| Flag | Default | Description |
|---|---|---|
-m, --model <name> | Configured deployment, else gpt-5-codex | Foundry deployment name for this run. |
-e, --reasoning-effort <level> | Configured value, else medium | Reasoning effort: none, low, medium, high, xhigh, or default (omits the -c model_reasoning_effort override and lets Codex use its own built-in default). |
-p, --port <port> | Configured value, else 8788 | Loopback port for the passthrough. |
--print-env | false | Run the passthrough in the foreground and print the launch command instead of starting Codex. |
--safe | false | Keep Codex approval prompts and sandbox enabled. |
The positional ARGS are native codex exec arguments, forwarded verbatim.
The run produces no output and exits. Read ~/.pks-cli/codex-passthrough-failures.log. Auth failures, non-2xx upstream responses, and response.failed events land there instead of on the terminal.
A quoted instruction arrives split or empty. Quote the whole instruction as one shell argument, as in the examples, and place it after the native resume arguments.
Exit code 1 pointing at pks foundry init. Authentication or resource selection is missing.
Exit code 127. The codex binary is not on PATH.