Repository navigation
Test: Capture the Codex TUI's User-Agent live instead of inferring it - #1375
Conversation
#1337 added "codex-tui" and "codex_cli_rs" from Codex's source plus `strings` on the shipped binary, with no live capture — the only two entries in knownClients not read off real traffic, and the weakest part of the fix for that review's second blocker. The reviewer asked for a capture; this is it. Driven through the proxy by allocating a pty directly (this environment has no controlling terminal, so `script` cannot) and typing a prompt into the real interactive TUI. Both tokens confirmed, and the first of them on the TUI's own /backend-api/codex/responses inference requests rather than only on its chatter — which is the case that matters, since that is the traffic whose cost and tokens get attributed. Two things the capture corrected or strengthened: - The third UA field is the TERM value — "unknown" under `codex exec`, the terminal's name under the TUI. The invented fixtures said "unknown" for both. Parsing keys on the product token so nothing broke, but the fixtures now carry the real shapes. - The capture caught an auto-update mid-session, so it holds both 0.160.1 and 0.162.1. Both parse identically, which is the only evidence in this suite that the UA shape is stable ACROSS releases rather than pinned to the one build everything else was read from. The docs' version caveat is narrowed accordingly, and Linux is now called out on its own rather than bundled in with it. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Alan Cha <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
clawgenti
left a comment
There was a problem hiding this comment.
Replaces the inferred Codex TUI User-Agent fixtures with ones captured from a real TUI session driven through the proxy over a pty — including the TUI's own inference requests and a 0.162.1 mid-auto-update sample — with the knownClients comment and docs updated to match. One docs nit below; nothing blocking.
- nit
docs/agents/codex.md:146— the codex-tui row omits the trailing(codex-tui; <version>)comment the captured UA carries, while the codex_exec row documents its own.
Reviewed by clawgenti using the github-pr-review skill
| | `codex-mcp-client/<version>` | its MCP client (`/backend-api/ps/mcp`) | | ||
| | `codex-tui/<version> (<os>; <arch>) unknown` | the interactive TUI — i.e. plain `codex` | | ||
| | `codex_cli_rs/<version> (<os>; <arch>) unknown` | anything sent before its app-server finishes initializing | | ||
| | `codex-tui/<version> (<os>; <arch>) <term>` | the interactive TUI — i.e. plain `codex` — including its inference | |
There was a problem hiding this comment.
nit: the captured TUI User-Agents in the new test fixtures carry a trailing comment — e.g. codex-tui/0.160.1 (Mac OS 26.3.0; arm64) xterm-256color (codex-tui; 0.160.1) — but this row doesn't mention it, while the codex_exec row above documents its own optional trailing (codex_exec; <version>) comment. A matching "sometimes with a trailing (codex-tui; <version>) comment" here would keep someone matching live proxy logs against this table from wondering about the suffix.
Correction to this PR's descriptionI wrote that That is wrong. Going back over the captured events, every {"phase":"request","httpMethod":"GET","httpPath":"/backend-api/codex/responses"}
{"phase":"response","httpMethod":"GET","httpPath":"/backend-api/codex/responses",
"statusCode":405,"error":{"kind":"backend_error","code":"405"},"bytesDown":31}
What this PR's change still rests on, unchangedThe User-Agent tokens themselves, which is all this PR touches: The real open question this surfacedTUI inference has never been observed through Cortex. The TUI attempts a WebSocket on the inference path, Cortex 405s it, and in five driven runs I never captured the HTTPS fallback completing — 164 events in one session with zero parsed inference. Tracking it on #1365 rather than widening this PR. It may be a harness limitation (I cannot reliably drive a TUI turn to completion non-interactively) or a genuine observability gap for the TUI — and those need different answers. Assisted-By: Claude (Anthropic AI) [email protected] |
mrsabath
left a comment
There was a problem hiding this comment.
Replaces two inferred Codex User-Agent fixtures with live-captured ones and corrects a detail the inference got wrong — the third field is the TERM value, not a literal unknown. The parser keys only on the product token, so nothing was broken; the value is that the fixtures now carry real strings, and the incidental mid-session auto-update gives the suite its only cross-release evidence.
What I verified
- The four new fixtures parse as asserted. Ran all of them, plus the two they replace and
codex_vscode, throughParseUserAgenton currentmain. All seven match their expectedName/Version, including both0.162.1strings. The trailing(codex-tui; 0.160.1)comment is correctly ignored. - The "key on the product token" reasoning holds.
ParseUserAgentcuts at the first space beforestrings.Cut(token, "/"), so a changed third field cannot reach the parse. That is why swappingunknownforxterm-256colorbreaks nothing. - The recovery premise is real.
refs/pull/1337/headis9202dde, which is inmainand matches the head this PR says the merge took.xterm-256colorappears nowhere inmain'score/pipeline/ordocs/agents/, andmainstill carries the inferredunknownfixtures atclient_test.go:230-231. So the content is genuinely absent frommain. - Test plan claims.
core/pipelineandcore/sessionboth pass on this branch;go vetandgofmt -lclean.
Summary
Areas reviewed: Go (fixtures + the knownClients comment), Docs
Commits: 1, signed off, imperative subject at 69 chars
CI: 28/28 passing (Spellcheck skipped)
Three findings, all in the docs table and all cosmetic — the code change itself is correct. The codex_exec row is the one worth fixing: this PR teaches the reader that the third field is TERM, then leaves one row spelling that same field as a literal. The third finding pre-dates this PR; I mention it only because you are editing that exact table.
| | `codex-mcp-client/<version>` | its MCP client (`/backend-api/ps/mcp`) | | ||
| | `codex-tui/<version> (<os>; <arch>) unknown` | the interactive TUI — i.e. plain `codex` | | ||
| | `codex_cli_rs/<version> (<os>; <arch>) unknown` | anything sent before its app-server finishes initializing | | ||
| | `codex-tui/<version> (<os>; <arch>) <term>` | the interactive TUI — i.e. plain `codex` — including its inference | |
There was a problem hiding this comment.
suggestion: this PR establishes that the third UA field is the TERM value, and generalizes both TUI rows to <term> — but the codex_exec row two lines above still hardcodes unknown for the same field.
The row is not wrong: codex exec runs with no TTY, so unknown genuinely is its TERM, and your test comment says exactly that. But the table now spells one field two ways with nothing on the page saying they are the same field, so it reads as though exec has a literal there and the TUI has a variable.
Either <term> with a note that exec reports unknown, or keeping the literal and saying why it is fixed for that one, would leave the table self-consistent.
| | `codex-mcp-client/<version>` | its MCP client (`/backend-api/ps/mcp`) | | ||
| | `codex-tui/<version> (<os>; <arch>) unknown` | the interactive TUI — i.e. plain `codex` | | ||
| | `codex_cli_rs/<version> (<os>; <arch>) unknown` | anything sent before its app-server finishes initializing | | ||
| | `codex-tui/<version> (<os>; <arch>) <term>` | the interactive TUI — i.e. plain `codex` — including its inference | |
There was a problem hiding this comment.
nit: <term> is introduced here as a placeholder but never expanded anywhere in this page. The explanation — that it is the TERM value, unknown under codex exec and the terminal's name under the TUI — lives only in client_test.go's comment, which a reader of the docs will not see.
One clause after the table would close it, and it is the detail the capture actually corrected, so it seems worth stating where people read it.
| | `codex-mcp-client/<version>` | its MCP client (`/backend-api/ps/mcp`) | | ||
| | `codex-tui/<version> (<os>; <arch>) unknown` | the interactive TUI — i.e. plain `codex` | | ||
| | `codex_cli_rs/<version> (<os>; <arch>) unknown` | anything sent before its app-server finishes initializing | | ||
| | `codex-tui/<version> (<os>; <arch>) <term>` | the interactive TUI — i.e. plain `codex` — including its inference | |
There was a problem hiding this comment.
nit, and pre-existing rather than introduced here — I checked main and it reads the same, so this is not a regression from this PR.
The prose above this table says Codex "sends two product tokens" and that the version is "the field after the first slash in both", but the table lists four rows and knownClients claims four tokens (codex_exec, codex-mcp-client, codex-tui, codex_cli_rs).
Flagging it only because this PR is already editing this table, so it is a one-word fix in passing. Equally fine to leave for its own change.
Four review comments on one table, three of them this PR's own doing. - The `codex_exec` row hardcoded `unknown` for the third field while this PR generalised both TUI rows to `<term>`. Same field, spelled two ways, with nothing saying they were the same — so it read as though exec had a literal and the TUI a variable. Now `<term>` in all three. - `<term>` was introduced as a placeholder and expanded only in client_test.go's comment, which no reader of the docs sees. Now stated after the table: it is TERM, `unknown` under `codex exec` which has no TTY, the terminal's own name under the TUI — plus the part that makes it matter, that nothing reads the field, because matching is on the product token before the first slash and a varying TERM therefore does not split one agent into several rows. - The `codex-tui` row omitted its trailing `(codex-tui; <version>)` comment, which the captured fixtures carry and which the `codex_exec` row documents for itself. Added, so someone matching live proxy logs against this table is not left wondering. - "sends two product tokens ... the field after the first slash in both" against a four-row table: pre-existing on main rather than a regression here, as the reviewer noted, but a one-word fix in a table this PR is already editing. Verified against knownClients, which has exactly four entries folding to `codex`. Docs only; no behaviour change. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Alan Cha <[email protected]>
|
All four applied in 4401bde — thanks, and three of them were this PR's own mess. @mrsabath's And the undefined placeholder is the one that bothered me most once pointed out: I put @clawgenti's trailing-comment nit — added to the The "two product tokens" / four-row contradiction — took it, since the table was already being edited. Verified against the code rather than counting rows: Docs only, no behaviour change, Assisted-By: Claude (Anthropic AI) [email protected] |
Recovers a commit pushed to #1337 but not included at merge time — the merge took head
9202dde9while this landed just after, so it is not in main. Same stale-head race as #1315/#1326, not a code issue. Cherry-picked cleanly onto current main and re-verified there.What this adds
#1337 fixed its reviewer's second blocker by adding
codex-tuiandcodex_cli_rstoknownClients, but those two strings were inferred — read off Codex's Rust source atrust-v0.160.1plusstringson the shipped binary. They were the only entries in that map not taken from real traffic, and the reviewer explicitly asked for a live capture.This is that capture. Driven by allocating a pty directly (this environment has no controlling terminal, so
scriptfails withtcgetattr/ioctl: Operation not supported on socket), exec'ing barecodex, sizing the pty viaTIOCSWINSZ, then typing a prompt into the real interactive TUI.Both tokens confirmed — and
codex-tuiappears on the TUI's own/backend-api/codex/responsesinference requests, not just its chatter, which is the traffic whose tokens and cost get attributed.Two things the capture gave that inference had not
unknownundercodex exec,xterm-256colorunder the TUI. The fixtures Feat: Codex support — configure, agent recognition, and docs #1337 shipped saidunknownfor both. Parsing keys on the product token so nothing was broken, but the fixtures now carry the real strings rather than invented ones.0.160.1and0.162.1, parsing identically. That is the only evidence in the suite that the UA shape is stable across Codex releases rather than pinned to the single build everything else was read from — sodocs/agents/codex.md's version caveat narrows, and Linux is called out on its own instead of bundled in with it.Test plan
gofmt -l,go vetclean;core/pipelineandcore/sessionsuites pass on current mainName: "codex"with the right versionclaude-codekey — no interactionRelated: #942, #1337, #1365 (ticks that issue's live-TUI-capture item).
Assisted-By: Claude (Anthropic AI) [email protected]
Summary by CodeRabbit
Bug Fixes
Documentation