Skip to content

[PR] test/fix(#7013): label prompt mass inside 'other' for google/responses wire shapes (stacked on #7092) - #7118

Closed
ZzXxYy1234 wants to merge 1 commit into
ranxianglei:2026-11-18_rcagg-doom-gate-pricing-mismatchfrom
ZzXxYy1234:fix/7013-prompt-mass-clause
Closed

ZzXxYy1234 wants to merge 1 commit into
ranxianglei:2026-11-18_rcagg-doom-gate-pricing-mismatchfrom
ZzXxYy1234:fix/7013-prompt-mass-clause

Conversation

@ZzXxYy1234

Copy link
Copy Markdown

Stacked on #7092 — do not merge before it lands. Base here is that PR's head branch (2026-11-18_rcagg-doom-gate-pricing-mismatch), not master; once #7092 merges I'll retarget this to master.

Why

#7092 prices the window-fit gates off breakdown.prompt (PROMPT_BODY_KEYS), but breakdown.other is bucketed by the ANTHROPIC key names (messages / tools / system / everything-else). google carries its prompt in contents/systemInstruction and responses in input/instructions — none of them is an anthropic bucket name, so that mass lands in other while ALSO being the prompt number that trips the gate. The measured-doom 413 then says:

messages ~0 · tools[] ~0 · system ~0 · other ~1,200,008 (non-prompt, excluded from the window budget; top field: contents ~1,200,001 tokens ≈3,600,004 B)

…i.e. it names the supposedly-EXCLUDED bucket as the reason the body was refused.

What

  • src/preflight.ts: RawBodyBreakdown gains otherPrompt — the part of other that is still prompt mass for the wire format. Accumulated at the same string leaf as prompt, so the two can never drift.
  • src/server.ts: measuredBreakdownClause splits other on it:
    other ~1,201,100 (prompt mass ~1,200,009 counted toward the window, 1,091 excluded as non-prompt; top field: contents …)
    When otherPrompt === 0 (anthropic/openai, where other really is transport like dsh_session_log) the previous wording is byte-identical.
  • tests/issue7013-prompt-mass-google-responses.test.ts (new, 6 cases): attribution + clause wording for google/responses, anthropic/openai controls, measuredOutbound prompt-mass pricing across all four protocols.
  • tests/raw-body-walk-depth.test.ts: one whole-object expectation gains otherPrompt: 0.

Verification

node --import ./tests/preload-test-env.mjs --import tsx --test tests/issue7013-prompt-mass-google-responses.test.ts   # 6/6
node --import ./tests/preload-test-env.mjs --import tsx --test tests/raw-body-walk-depth.test.ts tests/issue4079-egress-window-fuse.test.ts   # 22/22
npx tsc --noEmit --project tsconfig.json   # clean

The new assertions fail on the parent branch and pass with the patch (red first).

@ranxianglei ranxianglei changed the title test/fix(#7013): label prompt mass inside 'other' for google/responses wire shapes (stacked on #7092) [PR] test/fix(#7013): label prompt mass inside 'other' for google/responses wire shapes (stacked on #7092) Nov 18, 2026
@ZzXxYy1234 ZzXxYy1234 closed this Nov 18, 2026
@ZzXxYy1234

Copy link
Copy Markdown
Author

This PR is superseded by ccfee8ad on the base branch ("align the breakdown's named buckets with the prompt mass on every lane", #7090), which solves the same symptom the right way.

My patch added an otherPrompt sub-total plus a clause wording split, so the 413 message could explain that part of other was actually prompt mass. The base branch instead fixes the bucket assignment itself (PROMPT_KEY_BUCKET: input/contents → messages, systemInstruction/instructions → system), which makes prompt === messages + tools + system and prompt + other === total hold on every lane by construction.

With that in place the otherPrompt branch would be dead code (other can no longer contain prompt mass), and the added tests asserting prompt keys land in other would now fail — so this branch is redundant rather than worth rebasing. Closing it to avoid stacking a conflicting change.

For the record: the prompt-mass clause assertions on the google/responses lanes and the four-protocol measuredOutbound check are the parts still worth having; they are covered by the base branch tests now, so if a gap shows up this can come back as a test-only PR. Thanks!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants