Codex handoff
Pass a complete, self-contained task through stdin:
set -o pipefail
codex exec \
--yolo \
--cd "$workspace" \
--strict-config \
-c model_reasoning_effort=medium \
--json \
--color never \
--output-last-message "$result" \
- < "$prompt" \
| tee "$events"
- Parse
$eventsas JSONL; read$resultfor the final response. - Capture
.thread_idfrom the first event (thread.started) to resume the session later withcodex exec resume <id>. - Keep every session in
~/.codex/sessions/<YYYY>/<MM>/<DD>/rollout-<timestamp>-<thread_id>.jsonl.- Never override
CODEX_HOME, use a temporary Codex home, or use--ephemeralfor handoffs. - Its
turn_contextevents record the effective model and reasoning effort; the JSON event stream does not.
- Never override
- Add
--output-schema <schema.json>when the caller requires a machine-validated response. - Keep
-c model_reasoning_effort=medium; without it runs can default tonone.- Raise to
highfor hard tasks (deep reviews, tricky debugging).
- Raise to
- Add
--add-dir <dir>,--skip-git-repo-check,--image, or--model(e.g.--model gpt-5.6-sol) only when the task requires it. - Put the top-level
--searchbeforeexecwhen live web search is required. - Recheck
codex exec --helpafter CLI upgrades; the installed binary is authoritative.