Issue: `unmapped token field: completion_thinking_tokens` on Anthropic thinking requests
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
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
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:
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_tokenslikecompletion_reasoning_tokensin theanthropicrules. - Normalize the key to
completion_reasoning_tokensin 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)
- Configure a provider with
type: anthropic. - Send a streaming
POST /v1/messagesrequest with extended thinking enabled, for example"thinking": {"type": "enabled", "budget_tokens": 4096}, to a Claude model on that provider. - Open the usage entry for that request in the dashboard.
- 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
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ENTERPILOT/GoModel
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 55/100
ENTERPILOT/GoModel#1182 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 15/100
ENTERPILOT/GoModel#1170 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
ENTERPILOT/GoModel#1165 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 Half a day Newbie friendliness 35/100
ENTERPILOT/GoModel#1154 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
ENTERPILOT/GoModel#1107 ·
Maintainers usually reply within 1 day
All issues in ENTERPILOT/GoModel
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
praetorian-inc/augustus#334 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
TestTOMLBigFileParsesInLinearTime: a 1s wall-clock bound on a 3 MB parse fails under load (1.27s)Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100