Skip to content

test(proxies): PR #2164 cached_tokens emission is unpinned for the codex CLI transport and commandcode-proxy #3114

Closed

Description

@dezren39

Finding

PR #2164 ("fix(proxies): emit prompt_tokens_details.cached_tokens from session usage", for opencode#394) added cached_tokens emission to THREE proxies, but tests pin only two of the five emission paths:

Pinned by tests:

  • codex-proxy app-server transport — bin/codex-proxy.test.mjs asserts cached_tokens: 39 from cachedInputTokens.
  • muse-proxy warm path — bin/muse-proxy.test.mjs asserts cached_tokens: 40 from cacheReadTokens.

Unpinned (still unpinned on current main):

  1. codex-proxy CLI transport (runCodexOnce) — parses cached_input_tokens from turn.completed usage events and threads cacheReadTokens into both response shapes. The test stub was even extended in the same PR to emit "cached_input_tokens":93 (bin/codex-proxy.test.mjs:65), but no assertion anywhere in the suite reads that 93 back out — a regression in the CLI parse or plumbing would be invisible.
  2. commandcode-proxy (both streaming and non-streaming responses) — emits prompt_tokens_details.cached_tokens from the ACP result's cacheReadTokens, and bin/commandcode-proxy.test.mjs contains no cached/cacheRead mention at all.

Evidence

  • PR: fix(proxies): emit prompt_tokens_details.cached_tokens from session usage (opencode#394) #2164 (merged, commit 1d00ef9)
  • Current main 4c34c57c10ed7ef9aa979e90277e9440459dd52f:
    • bin/codex-proxy.mjs:933-934 — CLI path parses event.usage.cached_input_tokens into cacheReadTokens; :1157 — response emits prompt_tokens_details.cached_tokens when > 0.
    • bin/codex-proxy.test.mjs:65 — stub emits cached_input_tokens: 93; the only cached_tokens assertion in the file is :442 (app-server, 39).
    • bin/commandcode-proxy.mjs:1286 and :1311 — streaming and non-streaming emission; grep cached bin/commandcode-proxy.test.mjs returns nothing.
    • The ACP layer does produce the value (bin/commandcode-proxy.mjs:791, usage.cacheReadTokens since 169d594), so the commandcode emission is live code, not dead plumbing — it is simply untested.

Why it matters

Cached-token reporting is how the fleet sees cache hit rates for these routes (the point of opencode#394); the CLI transport is codex-proxy's default path, so the most-used emission is the one with no regression net. The stub data already exists — the tests just never assert on it.

Acceptance criteria

  • A codex-proxy test drives the CLI (non-app-server) transport with a stub emitting cached_input_tokens and asserts the response's usage.prompt_tokens_details.cached_tokens equals it (the existing stub's 93 is the natural fixture).
  • A commandcode-proxy test drives a session whose ACP result carries cacheReadTokens and asserts prompt_tokens_details.cached_tokens in the response (streaming or non-streaming; both share the result object).
  • A zero/absent cache value still omits prompt_tokens_details entirely (existing conditional shape preserved).

Activity

  1. added
    kind/testTest coverage, test infrastructure, or test-only fixes
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/lowNice to have; do when convenient
    queue/queuedHas a queued task in the Supabase agent queue
    effort/sSmall: expected under 2 hours of work
    app/codex-proxybin/codex-proxy.mjs fleet proxy
    on Oct 31, 2026
  2. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    agent-note:v1 — Agent: pr-diff-review-b; state: filed. Filed from PR diff review lane B (PR #2164, commit 1d00ef9): cached_tokens emission unpinned for codex CLI transport and commandcode-proxy on main 4c34c57. Enqueued as a repo-task/v1 triage packet on repo-health-code-pilot.

  3. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Oct 31, 2026
  4. 13 remaining items

  5. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    on Oct 31, 2026
  6. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · parked

  7. added
    queue/claimedQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Oct 31, 2026
  8. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    Lane B worker resumed task 4536 (parked on CI pending for PR #3127). Fresh check: PR #3127 OPEN @3aa150cb1, Codex review completed with no findings, but no CI check runs have started in >1h (runner backlog). Verifying the test-only change first-hand on the laptop worktree, then merging under the standing directive if green.

  9. dezren39 commented on Oct 31, 2026

    @dezren39
    MemberAuthor

    Done: PR #3127 squash-merged (9d8e191). Test-only change (+132/-0, bin/codex-proxy.test.mjs + bin/commandcode-proxy.test.mjs). Codex review on head 3aa150c: completed, no findings. New ACP test verified passing on the laptop (1.6s). The new codex CLI test could not be verified first-hand: the codex-proxy test harness currently fails environmentally on the laptop (load ~42) — the pre-existing main test 'successful run is unchanged in both modes' fails identically (HTTP 500, ~19s) on clean main, so the failure is pre-existing and unrelated to this PR; GitHub CI also never started any check run on the PR (fleet runner backlog). Main CI is the backstop for the codex CLI assertion.

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

Metadata

Metadata

Assignees

Labels

app/codex-proxybin/codex-proxy.mjs fleet proxyapp/commandcode-proxybin/commandcode-proxy.mjs fleet proxyeffort/sSmall: expected under 2 hours of workkind/testTest coverage, test infrastructure, or test-only fixespriority/lowNice to have; do when convenientsource/pr-diff-reviewFiled by the pr-diff-review jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions