Run a sub-agent (Codex exec) and capture JSONL
Use the bundled runner script to avoid manually picking filenames/paths for the JSONL log.
Runner
- Script:
~/.codex/skills/codex-exec-sub-agent/scripts/run.sh - Default runs dir:
~/.codex/sub_agent_runs/(override withCODEX_SUBAGENT_RUNS_DIR) - Prints: the full path to
run.jsonlas the last line on stdout
How to call
Important: when you ask a “main agent” to run this, configure that main agent’s timeout to at least ~10 minutes. Otherwise the parent may time out while the nested codex exec is still running (even though the sub-agent would eventually finish).
Pass the prompt via stdin (recommended for long prompts):
cat prompt.txt | ~/.codex/skills/codex-exec-sub-agent/scripts/run.sh
Or pass it as an argument (ok for short prompts):
~/.codex/skills/codex-exec-sub-agent/scripts/run.sh "Do X, then write results to /full/path/output.md"
How to think about the prompt
Treat the sub-agent prompt like a mini-brief:
- Be explicit about the outcome: what “done” looks like.
- Limit scope: what to include vs what to ignore.
- Set output rules: format, length, tone, structure (especially if non-technical).
- Prefer deterministic artifacts: if you want a file created/updated, tell it the full path.
Notes
- Prefer full paths in prompts for any files you want created/updated.
- The JSONL log is for inspection/debugging; treat the “real output” as a file path you instruct in the prompt.