# NousResearch/hermes-agent · reasoning_tokens extraction from completion_tokens_details

## Open now

- Nothing open on GitHub.

These issues and PRs concern a bug where reasoning_tokens is always reported as 0 in chat completions mode, because usage normalization reads from output_tokens_details instead of completion_tokens_details. Members address fixes and broader reasoning/thinking token exposure across the API.

## TL;DR

- 3 member(s): 0 open issue(s), 1 closed issue(s), 0 open PR(s), 1 merged PR(s), 1 PR(s) closed without merging.
- A fix was merged to main in PR #57340. Verify it addresses your case.
- **Recommended:** read PR #57340 (and any competing PRs below) before filing. Confirm the merged change covers your symptom.

## Maintainer resolution verdict

- Internal-tracker verdict over this cluster's issue members: `unresolved`. This is distinct from the fix status above. Weigh it yourself.

## How this cluster was grouped

- Link evidence (`STRUCTURAL_SPANNING`): every member is connected by structural evidence: shared changed files, or a closing/superseded reference.
- Pairwise link density `0.67`: the share of member pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36. `1.00` means every pair is linked.

## Closed / duplicate issues

- #18466: \[Bug\]: reasoning_tokens always 0 for chat_completions mode — normalize_usage only extracts from output_tokens_details, missing completion_tokens_details

## Prior & competing PRs

- **#57340: fix(usage): capture reasoning_tokens from completion_tokens_details on chat_completions**. merged to main · fix tier `verified`
  - maintainer direction: category `merged`
  - files: `agent/usage_pricing.py`
  - fix hunks:
  - `agent/usage_pricing.py`

    ```diff
    @@ -820,9 +820,22 @@ def normalize_usage(
             input_tokens = [redacted:secret-assignment] prompt_total - cache_read_tokens - cache_write_tokens)
     
         reasoning_tokens = 0
    +    # Responses API shape: output_tokens_details.reasoning_tokens.
    +    # Chat Completions shape (OpenAI, OpenRouter, DeepSeek, etc.):
    +    # completion_tokens_details.reasoning_tokens. Reading only the former
    +    # left reasoning_tokens=0 for every chat_completions reasoning model —
    +    # hidden thinking was invisible in session accounting even though it
    +    # dominates output spend on models like deepseek-v4-flash (measured:
    +    # single calls burning 21K reasoning tokens to emit 500 visible tokens).
         output_details = getattr(response_usage, "output_tokens_details", None)
         if output_details:
             reasoning_tokens = [redacted:secret-assignment] "reasoning_tokens", 0))
    +    if not reasoning_tokens:
    +        completion_details = getattr(response_usage, "completion_tokens_details", None)
    +        if completion_details:
    +            reasoning_tokens = _to_int(
    +                getattr(completion_details, "reasoning_tokens", 0)
    +            )
     
         return CanonicalUsage(
             input_tokens=[redacted:secret-assignment]
    ```
- **#18484: fix(usage): read reasoning_tokens from completion_tokens_details (chat completions)**. closed without merge
  - maintainer direction: category `implemented_elsewhere`; implication `superseded`; refs `3a122ba4acaabec5768ceddb46da82e43c382d7c`, `#57340`

## Fix status

- Merged to main in PR #57340 (cited above). No release data is tracked. Verify downstream.
- Fix last verified (merged) `2026-07-02`.
- Subsystem: `agent`
