feat: add the Codex agent driver (@agentry/codex) - #3
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
@agentry/codex, a driver that drives the Codex CLI headlessly viacodex exec --jsonand normalizes its native thread/item event stream into the shared AgentryAgentEventmodel — the same contract@agentry/claudeimplements. Wires it into the CLI soagentry test/recordcan target Codex withuse: { 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).
parseCodexEventis a pure mapping:codex exec --json)thread.startedrun.startitem.completed{agent_message}message(assistant)item.started/completed{command_execution}tool_use/tool_result(toolshell)item.started/completed{file_change}tool_use/tool_result(toolapply_patch)item.*{mcp_tool_call}mcp_request(best-effort)turn.completed.usageusageCodex emits no terminal event, so
run.endis synthesized on process exit (mirrors the Claude driver's fallback). The driver spawns with stdin ignored socodex execnever blocks waiting on stdin.Capabilities
Known limitations (MVP)
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.reasoningitems are dropped;mcp_tool_callmapping is best-effort (not live-captured).allowedTools/disallowedTools/mcpConfig/maxBudgetUSD/appendSystemPrompthave no Codex-native equivalent and are ignored.Testing
pnpm typecheckclean; new-package tests green (parser +buildArgs); full suite 93 tests, 0 failures, no regressions.agentry doctorprobes the codex CLI and prints the driver's capabilities.Merge notes
main. Additively touches three files the sibling Gemini/Antigravity PRs also touch — theselectDriverswitch inpackages/cli/src/commands/run.ts,doctor.ts, and thetsconfig.json/vitest.config.tsaliases. Whichever PR merges later needs a trivial union-merge.chore/release-workflow. When that lands, add@agentry/codexto the fixed-version group and a changeset entry.🤖 Generated with Claude Code