Skip to content

feat: add the Codex agent driver (@agentry/codex) - #3

Merged
dortort merged 5 commits into
mainfrom
feat/codex-driver
Aug 8, 2026
Merged

feat: add the Codex agent driver (@agentry/codex)#3
dortort merged 5 commits into
mainfrom
feat/codex-driver

Conversation

@dortort

@dortort dortort commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Summary

Adds @agentry/codex, a driver that drives the Codex CLI headlessly via codex exec --json and normalizes its native thread/item event stream into the shared Agentry AgentEvent model — the same contract @agentry/claude implements. Wires it into the CLI so agentry test/record can target Codex with use: { agent: 'codex' }.

Delivers part of the Phase 5 "cross-agent adapters" roadmap item (spike-gated).

How it works

The event schema was captured live from codex-cli 0.147 (the Phase 0.11 feasibility spike). parseCodexEvent is a pure mapping:

Native (codex exec --json) AgentEvent
thread.started run.start
item.completed{agent_message} message (assistant)
item.started/completed{command_execution} tool_use/tool_result (tool shell)
item.started/completed{file_change} tool_use/tool_result (tool apply_patch)
item.*{mcp_tool_call} mcp_request (best-effort)
turn.completed.usage usage

Codex emits no terminal event, so run.end is synthesized on process exit (mirrors the Claude driver's fallback). The driver spawns with stdin ignored so codex exec never blocks waiting on stdin.

Capabilities

{ structuredStream: true, llmInterception: 'provider-config',
  mcpTransports: ['stdio'], toolPermissionControl: true, nativeBudgetControl: false }

Known limitations (MVP)

  • LLM interception is not wired to Agentry's proxy. Codex intercepts via model_providers.<id>.base_url (OpenAI/Responses API); Agentry's proxy speaks the Anthropic Messages API. Transcript record/replay works normally; wire cassettes do not apply to Codex.
  • reasoning items are dropped; mcp_tool_call mapping is best-effort (not live-captured).
  • allowedTools/disallowedTools/mcpConfig/maxBudgetUSD/appendSystemPrompt have no Codex-native equivalent and are ignored.

Testing

  • pnpm typecheck clean; new-package tests green (parser + buildArgs); full suite 93 tests, 0 failures, no regressions.
  • Parser fixtures are the live-captured codex-cli 0.147 stream.
  • agentry doctor probes the codex CLI and prints the driver's capabilities.

Merge notes

  • Branched off main. Additively touches three files the sibling Gemini/Antigravity PRs also touch — the selectDriver switch in packages/cli/src/commands/run.ts, doctor.ts, and the tsconfig.json/vitest.config.ts aliases. Whichever PR merges later needs a trivial union-merge.
  • No changeset included: the changesets system is being introduced separately on chore/release-workflow. When that lands, add @agentry/codex to the fixed-version group and a changeset entry.

🤖 Generated with Claude Code

dortort and others added 5 commits August 8, 2026 16:23
…workspace

New workspace package mirroring @agentry/claude; adds the tsconfig path, vitest alias, and CLI dependency so the driver resolves across typecheck, tests, and the CLI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ent model

Pure parseCodexEvent maps the thread/item stream (thread.started, item.started/completed{agent_message,command_execution,file_change}, turn.completed) into AgentEvents. Shell runs normalize to tool 'shell', patches to 'apply_patch'; usage comes from turn.completed; run.end is synthesized on process exit since Codex emits no terminal event. Schema captured live from codex-cli 0.147.

Constraint: Codex exec emits no terminal run.end and reports no per-run cost
Rejected: Wire Agentry's Anthropic LLM proxy into Codex | Codex speaks the OpenAI/Responses API and intercepts via model_providers.<id>.base_url, incompatible with the Anthropic proxy\nConfidence: high\nScope-risk: narrow\nDirective: Event schema captured from codex-cli 0.147; re-verify the stream if bumping Codex\nNot-tested: live mcp_tool_call and reasoning items (best-effort / dropped in MVP)\nCo-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Fixtures are the live-captured codex-cli 0.147 event stream; asserts tool calls, assistant messages, usage, and the synthesized run.end.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
selectDriver(config.use.agent) routes 'codex' to CodexDriver and defaults to Claude; doctor probes the codex CLI and prints its capabilities.

Constraint: Parallel driver branches each extend this switch; kept minimal for clean union merges
Confidence: high
Scope-risk: narrow
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dortort dortort self-assigned this Aug 8, 2026
@dortort
dortort merged commit 6344d4c into main Aug 8, 2026
1 check passed
@dortort
dortort deleted the feat/codex-driver branch August 8, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant