The Codex agent plugin integrates OpenAI’s Codex CLI, providing automatic metadata updates via shell wrappers, session introspection from JSONL rollout files, and native thread resumption.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ComposioHQ/agent-orchestrator/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Codex is OpenAI’s AI coding assistant CLI. The plugin:- Automatically resolves the Codex binary (npm global, Homebrew, Cargo)
- Injects
~/.ao/bininto PATH to wrapghandgitcommands - Updates metadata transparently when agents create PRs or switch branches
- Streams JSONL rollout files to extract token usage and session data
- Supports native thread resumption via
codex resume <thread-id>
This plugin requires Codex CLI. Install from OpenAI’s repository.
Installation
Configuration
Configure inagent-orchestrator.yaml:
Configuration Options
Codex model (e.g.,
o4-mini, o3-mini, gpt-4-turbo)Approval policy:
skip: Bypass all approvals and sandbox (--dangerously-bypass-approvals-and-sandbox)auto-edit: Never ask (--ask-for-approval never)suggest: Ask for untrusted operations only (--ask-for-approval untrusted)
Developer instructions passed via
-c developer_instructions=...Path to instructions file (preferred for long prompts)
Uses
-c model_instructions_file=...Automatic Metadata Updates
The plugin installs shell wrappers in~/.ao/bin/ that intercept gh and git commands:
Tracked Commands
| Command | Metadata Updated |
|---|---|
gh pr create | pr (URL), status (pr_open) |
git checkout -b <branch> | branch |
git switch -c <branch> | branch |
gh pr merge | status (merged) |
How PATH wrappers work
How PATH wrappers work
- Plugin prepends
~/.ao/binto PATH during agent launch - Wrapper scripts intercept
gh/gitcommands - Wrapper strips
~/.ao/binfrom PATH and calls the real binary - On success, wrapper parses output and updates metadata via
update_ao_metadata() - All other commands pass through transparently
~/.ao/bin and reused across all sessions.Wrapper Scripts
~/.ao/bin/gh
~/.ao/bin/git
~/.ao/bin/ao-metadata-helper.sh
Wrappers are versioned. The plugin only rewrites them if
.ao-version marker changes, minimizing disk writes.Session Introspection
Codex stores session data in date-sharded JSONL files:Finding Session Files
The plugin:- Recursively scans
~/.codex/sessions/(max depth 4) - Reads the first 4 KB of each
.jsonlfile - Matches
session_metaentries wherecwdequals the workspace path - Returns the most recently modified matching file
Extracting Data
The plugin streams JSONL files line-by-line (never loads entire file into memory):Cost Estimation
Token usage is aggregated fromevent_msg lines with type: "token_count":
Cost estimates are approximate. For accurate billing, check OpenAI’s usage dashboard.
Usage Examples
Spawn an Agent
- Resolves the Codex binary (cached after first call)
- Creates workspace and sets up wrappers
- Launches Codex with prompt included in command
- Monitors session file mtime for activity
Resume a Thread
threadId from the session JSONL and builds:
Check Session Cost
Advanced Features
Binary Resolution
The plugin auto-detects Codex installation on first launch:- Try
which codex - Check common locations:
/usr/local/bin/codex(Homebrew Intel)/opt/homebrew/bin/codex(Homebrew ARM)~/.cargo/bin/codex(Cargo)~/.npm/bin/codex(npm global)
- Fallback to
"codex"(let shell resolve)
Reasoning Models (o-series)
The plugin auto-detects o-series models and enables reasoning:model_reasoning_effort=high for o3/o4 models automatically.
Session File Caching
To avoid redundant filesystem scans, the plugin caches session file paths:getActivityState() and getSessionInfo() calls.
AGENTS.md Integration
The plugin appends a section toAGENTS.md in each workspace:
Troubleshooting
Wrappers not intercepting commands
Wrappers not intercepting commands
Cause: PATH not set correctly or wrappers not executableSolution:
- Check if
~/.ao/binis first in PATH: - Verify wrappers are executable:
- Check if real binaries exist:
Session file not found
Session file not found
Cause: No Codex session created yet, or cwd mismatchSolution:
- Check if Codex has created any sessions:
- Verify workspace path matches session_meta cwd:
- Wait for Codex to make its first API call (session files are created lazily)
Binary resolution fails
Binary resolution fails
Cause: Codex installed in non-standard locationSolution: Add Codex to PATH or create a symlink:
Metadata updates not persisting
Metadata updates not persisting
Cause: AO_DATA_DIR or AO_SESSION environment variables not setSolution: Check agent environment:Verify metadata file exists:
Activity detection shows 'idle' when agent is working
Activity detection shows 'idle' when agent is working
Cause: Codex writes to session file in bursts, not continuouslySolution: This is expected. Activity detection uses file mtime, which only updates when Codex makes API calls or writes events. During long reasoning periods (o-series models), the file may not be modified. Check process status with
ao status <session> for ground truth.Comparison with Other Agents
| Feature | Codex | Claude Code | Aider | OpenCode |
|---|---|---|---|---|
| Provider | OpenAI | Anthropic | Aider.chat | OpenCode |
| Auto-metadata | ✅ PATH wrappers | ✅ PostToolUse hooks | ❌ None | ❌ None |
| Cost Tracking | ✅ Full | ✅ Full | ❌ None | ❌ None |
| Resume Support | ✅ Native | ✅ Native | ❌ None | ❌ None |
| Binary Resolution | ✅ Auto | ❌ Manual (must be in PATH) | ❌ Manual | ❌ Manual |
| Session Files | JSONL (date-sharded) | JSONL (path-encoded) | Markdown | SQLite |
| Activity Detection | ✅ File mtime | ✅ JSONL events | ⚠️ Git commits | ❌ None |
Environment Variables
The plugin sets these variables in the agent environment:Session identifier for metadata lookups
Project identifier (set by caller, not the plugin)
Issue/ticket identifier if applicable
Prepended with
~/.ao/bin to enable command interception