Repository navigation
Description
Client or integration
Direct HTTP/API client (also affects pi/omo, which call OCX through openai-completions)
Area
Provider adapter
Summary
For Anthropic routes, thinking_tokens from the upstream usage block is dropped, so OCX always reports zero reasoning tokens on the Chat Completions surface (usage.completion_tokens_details.reasoning_tokens: 0). The responses bridge emits the same 0 default (output_tokens_details.reasoning_tokens).
Thinking itself does run. On the Chat surface, message.reasoning_content is present, and the same prompt sent to /v1/messages returns a thinking block with a non-zero usage.output_tokens_details.thinking_tokens.
Expected: map Anthropic output_tokens_details.thinking_tokens to OcxUsage.reasoningOutputTokens, so Chat and Responses clients report it as reasoning_tokens. Anthropic counts thinking inside output_tokens, which matches OpenAI's reasoning_tokens semantics.
Reproduction
Use a prompt that makes adaptive thinking engage. With trivial prompts the model skips thinking and upstream reports thinking_tokens: 0.
PROMPT="Find the number of ordered pairs (a,b) of positive integers with a,b <= 2000 such that a^2 + b^2 is divisible by 7*13 and gcd(a,b)=1. Give only the integer."
- Chat surface:
POST /v1/chat/completionswith{"model":"anthropic/claude-sonnet-5-5","reasoning_effort":"medium","max_tokens":32000,"messages":[{"role":"user","content":PROMPT}]}choices[0].message.reasoning_content: 179 characters (non-empty)usage.completion_tokens: 292usage.completion_tokens_details.reasoning_tokens: 0
- Messages surface, same prompt:
POST /v1/messageswiththinking: {type:"adaptive", display:"summarized"},output_config: {effort:"medium"}- content:
thinkingblock, thentext usage.output_tokens_details.thinking_tokens: 156
- content:
The same pattern shows up on claude-opus-5-5 and claude-haiku-5-5 at high effort (Messages: thinking_tokens 75 and 436). Their Chat-surface value was not captured separately. They take the same adapter path.
Suspected cause
usageFromAnthropic() in src/adapters/anthropic.ts (2.80.0 installed copy, roughly L608-636) maps input_tokens, output_tokens, cache_read_input_tokens and cache_creation_input_tokens. It never reads output_tokens_details.thinking_tokens, so reasoningOutputTokens stays unset. Downstream, src/chat/outbound.ts (L55-56) and src/bridge/internal.ts (L96) fill in the 0 default. The function is unchanged on main and dev as of 2026-10-07.
Possible fix (sketch, untested):
// inside usageFromAnthropic(), after the existing token reads
const details = isAnthropicRecord(usage.output_tokens_details) ? usage.output_tokens_details : undefined;
const thinking = details?.thinking_tokens;
const reasoningOutputTokens =
typeof thinking === "number" && Number.isFinite(thinking) && thinking >= 0 ? thinking : undefined;
return {
inputTokens,
outputTokens: output,
...(reasoningOutputTokens !== undefined ? { reasoningOutputTokens } : {}),
...(hasCache ? { /* unchanged */ } : {}),
};Not verified: whether mergeAnthropicUsage carries output_tokens_details through streaming message_delta frames. The streaming path may need the same field merged.
Version
2.80.0 (npm latest at time of report)
Operating system
Windows 11 (10.0.26200)
Provider and model
anthropic (OAuth) / claude-sonnet-5-5 (also claude-opus-5-5, claude-haiku-5-5)
Logs or error output
# /v1/chat/completions, anthropic/claude-sonnet-5-5, reasoning_effort=medium
reasoning_content chars 179
usage {"prompt_tokens":107,"completion_tokens":292,"completion_tokens_details":{"reasoning_tokens":0}}
# /v1/messages, same prompt, effort=medium
blocks ["thinking","text"] usage.output_tokens_details.thinking_tokens 156Impact
Chat and Responses clients can't tell whether Claude reasoned, and usage or cost reporting shows zero reasoning for every Anthropic route. While comparing models we first concluded that Sonnet 5.5 was not reasoning at all. That conclusion was wrong and came from this zero.
Checks
- I searched existing issues and documentation. (Closest: [Bug]: Anthropic adaptive thinking is requested with default display (omitted), so long Opus max-effort thinking reaches Chat clients as minutes of heartbeat-only silence #5824, a different issue about display=omitted)
- I removed secrets, tokens, account details, request credentials, and personal data.
Activity
Ingwannu commentedon Oct 8, 2026
Independently reproduced against dev bbab02a and opened draft fix #6721 at e0f539a. The mapper drops this optional breakdown; the existing streaming cumulative merge already retains the final message_delta object, so the fix needs no second streaming merge rule. Anthropic's official usage contract confirms thinking_tokens is a subset of output_tokens, not additional output.
Final regression on unchanged source:10pass/8fail. Patched focused suite:150pass/0fail(1035assertions,7files), covering JSON/SSE Chat/Responses, cumulative final usage, EOF terminal, refusal/error, explicit zero and malformed optional detail without total/cache changes. Structure/diff checks pass. Whole-root typecheck hit the180s cgroup deadline and remains unverified; docs build/broader suite/current-head CI and independent review are outstanding, so this is Draft, not a landed/released fix. No live provider call, security/privacy scan or runtime modification. Your diagnosis/projection is credited in the commit.
lidge-jun commentedon Oct 8, 2026
Fixed by #6721 (merged to
devas 1a8377d). Anthropic's reportedusage.output_tokens_details.thinking_tokensis now carried through asreasoning_tokensin translated Responses and Chat usage, for buffered and streamed replies. Output totals and spend are unchanged because thinking tokens are already a subset ofoutput_tokens. Thanks for the clear report.