fix(responses): emit input_tokens_details / output_tokens_details in Responses usage#229
Merged
Merged
Conversation
The Responses usage object only carried input/output/total tokens; strict consumers (Grok Build, codex-style) expect the *_tokens_details breakdown. - src/handlers/responses.js: mapUsage now emits input_tokens_details (text/audio/image/cached) and output_tokens_details (text/audio/reasoning), deriving text_tokens by subtracting cached/reasoning from the totals and preferring an explicit upstream text_tokens when present - test/responses.test.js: +2 — non-zero cached/reasoning subtraction, explicit text_tokens precedence; existing usage assertions updated to the richer shape
Owner
|
已合并,谢谢 🙏 这个 PR 有个你可能还不知道的巧合:它和我这边同期做的一件事正好是一条链的两半。 我前两天用付费 teams 账号校准了 DEVIN_CONNECT 响应里 cache 计数的 wire tag(issue #220): 合并后我用实测的真实数字串了一遍端到端:
顺带:既然现在出口通了,我把 已加入致谢名单,评级 A。 |
dwgx
added a commit
that referenced
this pull request
Jul 25, 2026
合入 warelik 六连(#224-#229):429 reset window 双链根因(resetMs 传输层透传 + 冷却落到 account-wide,原先 model-scoped 对 modelKey=null 的池选择结构性不可见)、 客户端断连不再罚账号(abort 统一识别,流式/非流式全路径不 failover 不烧配额,499)、 Grok/xAI self-ID 中和(a6-grok)、thinking signature 空串改省略、Responses usage 补 input/output_tokens_details、pair-chain 会话连续性新模块(600 行零依赖,默认关)。 合入 forrinzhao #219 的 codex content-policy 发现:落地为规则 (a7),并修根因 —— 工具描述 preamble 原本注入在 neutralizeClientIdentity 之后,导致 native 路径上 任何经由工具描述进来的触发词都绕过 a1-a6 整条防线。identity-neutralize 现覆盖 Claude Code / Cline / Grok / codex 四个客户端。 DEVIN_CONNECT cache_read_tokens=5 付费校准并改为默认解码(#220):缓存命中不再被 当作新鲜输入计费,与 #229 合起来端到端可见;'off' 可全关。setup.sh 在无 LS 二进制 的主机(macOS 典型)默认写 DEVIN_CONNECT=1 + 回环绑定。 2778/0 绿。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
中文 TL;DR
Responses usage 之前只有 input/output/total,缺 *_tokens_details。补齐
input_tokens_details / output_tokens_details(text 由 total 减 cached/reasoning 推导,
上游若给了显式 text_tokens 则优先)。
Summary
Spec-completeness for the OpenAI Responses API
usageobject, which strictconsumers (Grok Build, codex-style clients) expect to carry the
*_tokens_detailsbreakdown.
Fix
src/handlers/responses.jsmapUsage: emitinput_tokens_details(
text/audio/image/cached) andoutput_tokens_details(
text/audio/reasoning), derivingtext_tokensby subtractingcached/reasoningfrom the totals and preferring an explicit upstreamtext_tokenswhen present.Test plan
test/responses.test.js+2: non-zero cached/reasoning subtraction, explicittext_tokensprecedence; existing usage assertions updated to the richer shapenpm test→ 2763 pass / 0 failBranch is on current
master(v3.5.0), applies cleanly.