Commit Graph
1 Commits
Author SHA1 Message Date
yetone 09aa60d4ae gateway: a test that Claude Code on a Codex account is asked as Codex asks
qingchen060106 on X: gpt-6-astra (Codex account) seemed to spend the
plan faster from Claude Code than from Codex. Their screenshot: Claude
Code, astra high, 1 subagent: input 121K, cache read 1.6M, output 12.1K,
~$3.44; Codex, 4 messages: input 58.0K, cache 213K, output 2.4K, ~$0.915.

Checked the Messages -> Responses translation against Codex 0.162's
request (testdata/workdir/codex-0.162.0.json) with Claude Code 2.1.296's
own request (testdata/workdir/claude-code-2.1.296.json) through a fake
ChatGPT backend. No gap:
- prompt_cache_key is the same on every turn, and session-id/thread-id
  carry it, as Codex sends them;
- effort goes as picked (output_config high -> reasoning.effort high);
- the step's encrypted_content reasoning goes back before its call
  (carried in the call id, reasoning_carry.go);
- the system prompt and the 23 tools go once each, the billing line is
  cut, and nothing else is added to the input; turn 1's items are
  turn 2's prefix byte for byte.

What accounts for the difference: the fixed prompt per call is ~24.5K
tokens for Claude Code (o200k: instructions 4.1K, Claude Code's 23 tool
schemas 16.8K, input 3.6K) against ~13.0K for Codex (tools 4.0K), and
the session made several times as many calls (1.72M prompt tokens read
against 271K). Cache hits were higher through magpie (93% vs 79%). At
$10 in / $1 cached / $50 out both screenshots' costs come out as shown
(1.21 + 1.60 + 0.61; 0.58 + 0.21 + 0.12).

This adds TestClaudeCodeOnCodexSpendsAsCodex, which holds all of the
above: no test covered a Codex account's sealed reasoning through
Claude Code (only Grok's).

Run (on mica, at 05d25d8dc + this): go vet ./internal/gateway; go test
./internal/gateway -run 'TestClaudeCodeOnCodexSpendsAsCodex|
TestGrokReasoningGoesBackThroughOtherAPIs|TestSealedReasoningAskedOfGrokAlone|
TestHeadersCarry' -race -count=3: ok.
Broken by hand: carryReasoning returning dec as is -> red (second turn
has 5 items, no reasoning); sessionHeaders not setting session-id and
thread-id -> red on both turns.
Not tried: a real ChatGPT account; the full suite (test-only change).
2026-11-14 16:59:45 +08:00