Skip to content

token usage#774

Merged
nonoqing merged 5 commits into
GCWing:mainfrom
nonoqing:yuyiqing/dev
May 18, 2026
Merged

token usage#774
nonoqing merged 5 commits into
GCWing:mainfrom
nonoqing:yuyiqing/dev

Conversation

@nonoqing
Copy link
Copy Markdown
Collaborator

No description provided.

nonoqing added 5 commits May 18, 2026 20:48
…ead+creation sum

Previously the Anthropic adapter summed cache_read_input_tokens and
cache_creation_input_tokens into cached_content_token_count, which made any
downstream hit-rate metric (cached / prompt) wrongly count cache writes as
hits. Cache writes now go to the new cache_creation_token_count field.

Behavior change: Anthropic TokenUsageRecord.cached_tokens values will be lower
than pre-fix records for equivalent traffic, because creation tokens no longer
inflate the count. Hit-rate dashboards built on this should annotate the
discontinuity.
The OpenAI-compatible deserializer previously silently dropped DeepSeek's
prompt_cache_hit_tokens / prompt_cache_miss_tokens fields, leaving DeepSeek
cache hit rate permanently unknown. Map prompt_cache_hit_tokens (preferred)
or prompt_tokens_details.cached_tokens (fallback) to
cached_content_token_count so the hit-rate formula works for DeepSeek.
The agent_type field on DialogTurnData was added by an earlier
agent-tools refactor but three test fixtures in agentic_api.rs were
not updated, breaking `cargo test -p bitfun-desktop` (lib test
compile failure). None matches the field's documented use for
non-user-dialog or utility turns.
@nonoqing nonoqing merged commit 9bfb4b6 into GCWing:main May 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant