codex_exec
Execute guarded coding or shell work orders with file-scope whitelists, destructive-command blocking, and JSON ACK, so automated agents can modify Codex CLI workspaces safely and verifiably.
Instructions
Execute a scoped, guarded coding or shell Work Order on Codex CLI (default model="gpt-6.2-sol", reasoning_effort="max"). Enforces real-time destructive command blocking, file-scope whitelist/blacklist verification (allowed_paths/forbidden_paths with auto-revert), spin-loop circuit breaking, lean prefix stripping, persistent workspace cache lanes, and 2-field {"ok","err"} JSON ACK.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"task": "<task>",
"cwd": "<cwd>"
},
"name": "codex_exec"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | Yes | Absolute path to the target workspace directory. | |
| lane | No | Named cache lane within cwd. Keep "default" sequentially; use distinct names for parallel workers. | default |
| task | Yes | Imperative Work Order specifying exact objective, target files, specifications, constraints, and verification commands. | |
| async | No | ||
| model | No | Codex model slug. Defaults to "gpt-6.2-sol". | gpt-6.2-sol |
| images | No | ||
| profile | No | Reasoning effort preset: max=max (default), heavy=high, logic=medium, worker/fast=low. | max |
| sandbox | No | workspace-write | |
| lean_mode | No | ||
| timeout_sec | No | ||
| max_commands | No | Maximum shell commands allowed in a single work order before terminating. | |
| service_tier | No | Optional explicit Codex service_tier override. | |
| session_mode | No | "auto" (default) reuses the warm thread for (cwd, lane, model, effort, sandbox); "fresh" starts a new thread. | auto |
| strict_guard | No | Enable real-time destructive command blocking, live scope watchdog, max_commands cap, and spin-loop breaker (default true). | |
| allowed_paths | No | Strict file or directory whitelist relative to cwd (supports prefixes like "src/" and globs like "tests/*.test.ts"). Any mutation outside allowed_paths triggers a guard violation and optional auto-revert. | |
| fresh_session | No | Shortcut for session_mode="fresh". | |
| writable_dirs | No | ||
| forbidden_paths | No | Blacklist of relative files, directories, or globs Codex must never modify. | |
| reasoning_effort | No | Explicit reasoning_effort override (defaults to "max"). | |
| allow_destructive | No | Explicitly allow destructive git/filesystem commands (default false). | |
| max_files_changed | No | Optional hard cap on the number of distinct files allowed to change. | |
| auto_rotate_tokens | No | ||
| auto_revert_violations | No | Automatically revert unauthorized file mutations in Git repositories and delete unauthorized newly created files (defaults to true when allowed_paths or forbidden_paths is provided). | |
| kill_on_scope_violation | No | Immediately terminate the worker if a live file_change event violates allowed_paths or forbidden_paths (defaults to true when strict_guard and scope paths are set). | |
| use_silent_worker_prompt | No | ||
| enforce_structured_output | No |