Skip to content

feature: Codex support — detection, settings, parsed events, token and cost accounting #942

Open

Description

@huang195

Feature Description

Codex support on the agent integration contract.

Proposed Solution

Same checklist as OpenCode support:

  • Detect an installed Codex and locate its settings
  • Patch it to use localhost:47600 and the Cortex CA; ask before editing, support revert
  • Traffic parsed into typed events, not merely proxied
  • Token counts and cost correct for its wire format
  • Metrics aggregate alongside other agents
  • A tool inventory, or state explicitly that tool pruning is unsupported

Required artifact: a doc for Codex

This issue does not close on code alone. The doc is a deliverable like the code: it ships
in the same PR, or in a linked PR merged before this issue closes. A PR description or a
comment here does not count.

It is docs/agents/codex.md in this repo, linked from the root README's Any agent works line
and from the index in docs/agents/README.md (#939). It covers:

  • Enable and revert — the agentop configure commands for Codex, which file each one
    writes, and how to undo it by hand
  • CA trust — what Codex needs to trust the Cortex CA, and the symptom when it does not
  • What Cortex shows for it — which events are typed, which token and cost fields are
    filled, and what is partial or unsupported (e.g. tool pruning)
  • Verified depth — the Codex versions and platforms actually tested, and what was not
  • Known issues specific to Codex

cmd/agentop/README.md can carry the command reference too; it does not replace this page.

Additional Context

Part of the Cortex v0.9.0 release, stretch scope — deferred past v0.9.0 as the agent least
used internally, so it proves the least about the release. Depends on the agent integration contract.

Activity

  1. added this to the Release V0.9.0 milestone on Sep 10, 2026
  2. esnible commented on Sep 15, 2026

    @esnible
    Member

    The Codex CLI can be obtained from https://learn.chatgpt.com/docs/codex/cli

    Codex can be started under Cortex with abctl exec -- codex. Note that it reports

    ⚠ Falling back from WebSockets to HTTPS transport. unexpected status 405 Method Not Allowed: {"detail":"Method Not Allowed"}, url:
      wss://chatgpt.com/backend-api/codex/responses, cf-ray: ..., request id: ...
    

    Cortex doesn't yet see Codex inference traffic; it sees

     346   11:06:32.41   out   req      observe   initialize                                                                       chatgpt.com          
     346   11:06:32.60   out   resp     observe   initialize          200      185ms                                               chatgpt.com          
     353   11:06:32.60   out   req      observe   notifications/ini…                                                               chatgpt.com          
     353   11:06:32.75   out   resp     observe   notifications/ini…  204      152ms                                               chatgpt.com          
     364   11:06:32.75   out   req      observe   tools/list                                                                       chatgpt.com          
     364   11:06:33.00   out   resp     observe   tools/list          200      251ms                                               chatgpt.com
    

    Those events are related to MCP, not inferencing.

  3. esnible commented on Sep 20, 2026

    @esnible
    Member

    Codex can be permanently configured to use Cortex's proxy by adding env vars to ~/.codex/.env.

  4. Alan-Cha commented on Oct 2, 2026

    @Alan-Cha
    Member

    Split out #1239 for the OpenAI Responses API parser support that this issue's "typed events" / "token counts and cost" checklist items depend on — it's not Codex-specific (any future integration against OpenAI's newer API hits the same gap), so it's tracked on its own rather than as a sub-bullet here.

  5. Alan-Cha commented on Oct 5, 2026

    @Alan-Cha
    Member

    #1289 is relevant to this issue's "patch it... support revert" checklist item: the Claude Code implementation this would follow has a live bug where disable ignores any value change made since enable and silently overwrites it. Worth designing Codex's dotenv-based enable/disable with the fix (storing both Prior and Written, logging on mismatch) rather than copying the current behavior as-is.

  6. Alan-Cha commented on Oct 7, 2026

    @Alan-Cha
    Member

    #1315 (closes #1239) delivers the "typed events" and "token counts and cost" checklist items for Codex via real-traffic-verified Responses API support in inference-parser. Remaining open items here: settings-patching/persistent config, tool inventory, metrics aggregation, and docs.

  7. Alan-Cha commented on Oct 7, 2026

    @Alan-Cha
    Member

    #1326 recovers a commit that was pushed to #1315 but dropped at merge time (stale merge head, not a code issue) — tool-call capture for Codex's Responses API traffic.

  8. Alan-Cha commented on Oct 8, 2026

    @Alan-Cha
    Member

    #1337 delivers the "patch it... support revert" checklist item for Codex: agentop configure codex enable/disable/status, writing/reverting ~/.codex/.env (confirmed to be auto-loaded by the real Codex CLI). Deliberately scoped to the simple, one-shot Prior restore claude-code's disable already uses — not the stricter Written-based drift check tracked by #1289, which stays a separate pass across all three integrations.

    Remaining open items here: tool inventory, metrics aggregation verification, and the rest of docs/agents/codex.md.

  9. Alan-Cha commented on Oct 9, 2026

    @Alan-Cha
    Member

    #1337 now covers the remaining three checklist items as well, so it closes this issue:

    • Patch it / support revert — agentop configure codex enable/disable/status, writing ~/.codex/.env.
    • Metrics aggregate alongside other agents — codex_exec and codex-mcp-client fold to a canonical codex agent name. Verified live: series:codex appears in GET /v1/usage?group=agent with its token counts, and Codex's traffic moved out of the spawning agent's session into its own pending:codex@<pid> bucket. Its telemetry exporter (OTel-OTLP-Exporter-Rust) is deliberately not claimed.
    • Tool inventory — taking the "state explicitly that tool pruning is unsupported" option, with three independent reasons documented.
    • The doc — docs/agents/codex.md has all five required sections and is linked from the README's supported-agents table.

    Two findings documented rather than fixed, both worth knowing before this closes:

    1. Tokens aggregate, cost does not. No rate ships for Codex's model, which is subscription-served rather than per-token billed, so a turn counts as priceable-but-unpriced. If per-token rates for it are not public, "correct cost" may not be achievable for Codex rather than merely unimplemented — worth a second opinion on whether that satisfies the "cost correct for its wire format" item or needs its own issue.
    2. Codex never leaves its pending bucket. It sends none of the three session headers a laptop install reads, so its traffic groups per-process rather than per-session. Named in Known issues; a future Codex session header would just need adding to session.id_headers.

    Also surfaced while doing this, unrelated to Codex and not fixed here: tool-prune and inference-parser keep separate endpoint suffix lists, and only the parser's recognises /responses. The drift is silent — the parser reads a request the pruner skips as path_not_inference. Probably worth its own issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestnice to haveIt would be nice to have this fixed

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions