anthropics / anthropics/claude-agent-sdk-python

ResultMessage.usage is missing thinking token breakdown

未关闭
#540 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
8.1k
派生
1.3k
平均合并
2 天 31 分钟
30 天内合并 PR
1

描述

**The Problem**

Right now ResultMessage.usage lumps thinking tokens into output_tokens, but thinking tokens are actually billed differently from regular output. This makes it impossible to accurately
track costs.

When I set MAX_THINKING_TOKENS = 8000, I'm effectively authorizing up to $0.12 in thinking tokens per turn ($15/M), but I can't tell from the usage data how much of that was actually
used vs regular output.

**What I'm Seeing**

# Currently receiving:
{
"input_tokens": 9,
"output_tokens": 112, # thinking tokens mixed in here
"cache_read_input_tokens": 13916,
"cache_creation_input_tokens": 11227
}

**What I'd Expect**

Since the Anthropic API returns thinking counts separately, would be great to see them broken out:

{
"input_tokens": 9,
"output_tokens": 42,
"thinking_tokens": 70, # or separate thinking_input/thinking_output if available
"cache_read_input_tokens": 13916,
"cache_creation_input_tokens": 11227
}

**Why This Matters**

- Thinking tokens can easily be 50%+ of a run's cost
- When debugging expensive runs, it's hard to know if the model is thinking too much or outputting too much
- Different pricing should be visible in the usage stats

The raw API already exposes this, it's just a matter of surfacing it through the SDK's usage object.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。