Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Issue: `unmapped token field: completion_thinking_tokens` on Anthropic thinking requests

Open Beginner friendly
#1,183 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
backend

Research direction

Start with internal/usage/cost.go, where CalculateGranularCost flags the field, and check the anthropic entry in providerMappings and the informationalFields list. Then compare with internal/usage/stream_observer.go near line 268, which emits completion_thinking_tokens, and with the non-streaming rename in internal/providers/anthropic/anthropic.go. Done when a streamed thinking request no longer produces the unmapped-field caveat and the cost is unchanged.

Written by the indexing model from the issue text.

Description

bug

Describe the bug

Usage rows for Claude requests with extended thinking get the cost caveat unmapped token field: completion_thinking_tokens.

Related to #629 (closed). That fix made the Anthropic provider store thinking_tokens as completion_reasoning_tokens. The stream usage observer still records the same value as completion_thinking_tokens, and the cost calculator doesn't recognize that name.

Anthropic reports thinking tokens as usage.output_tokens_details.thinking_tokens. The stream usage observer copies every output_tokens_details field with a completion_ prefix, so the raw usage data gets completion_thinking_tokens:

https://github.com/ENTERPILOT/GoModel/blob/v0.1.102/internal/usage/stream_observer.go#L268

The anthropic entry in providerMappings only knows completion_reasoning_tokens, and informationalFields doesn't list completion_thinking_tokens either. CalculateGranularCost therefore flags it as unmapped:

https://github.com/ENTERPILOT/GoModel/blob/v0.1.102/internal/usage/cost.go#L202-L210
https://github.com/ENTERPILOT/GoModel/blob/v0.1.102/internal/usage/cost.go#L242-L252

The non-streaming Anthropic path already renames the same value to completion_reasoning_tokens:

https://github.com/ENTERPILOT/GoModel/blob/v0.1.102/internal/providers/anthropic/anthropic.go#L469-L470

The computed cost looks correct, because Anthropic includes thinking tokens in output_tokens and bills them at the output rate. Only the caveat is wrong. Two possible fixes:

  • Map completion_thinking_tokens like completion_reasoning_tokens in the anthropic rules.
  • Normalize the key to completion_reasoning_tokens in the stream observer, the same way the non-streaming path does.

GoModel version

0.1.102 (enterpilot/gomodel:0.1.102)

Steps To Reproduce (optionally)

  1. Configure a provider with type: anthropic.
  2. Send a streaming POST /v1/messages request with extended thinking enabled, for example "thinking": {"type": "enabled", "budget_tokens": 4096}, to a Claude model on that provider.
  3. Open the usage entry for that request in the dashboard.
  4. See the caveat unmapped token field: completion_thinking_tokens.

Screenshots/Logs (optionally)

Browser (if applicable)

N/A

Dominant language
Go
Stars
1.2k
Forks
111
Avg merge
15h 12m
Merged PRs (30d)
138

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ENTERPILOT/GoModel

All issues in ENTERPILOT/GoModel

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.