continue-custom/extensions
Nate Sesti ec7030d20b
fix: correct cache_hit_rate calculation and fix Vercel stream tool call handling (#10994)
* fix: correct cache_hit_rate calculation and remove duplicate emission

Two bugs in prompt_cache_metrics telemetry:

1. Duplicate emission: prompt_cache_metrics was emitted twice per API
   request — once using `actualInputTokens` and again using
   `fullUsage.prompt_tokens`. This doubled all event counts in PostHog
   and produced conflicting values.

2. Wrong denominator: cache_hit_rate was calculated as
   `cacheReadTokens / prompt_tokens`, but the Anthropic adapter maps
   `prompt_tokens` to only non-cached input tokens (`input_tokens`),
   excluding cache reads and writes. When caching works well, this
   produces ratios >> 1 (observed max: 89,892). The correct total is
   `prompt_tokens + cache_read_tokens + cache_write_tokens`.

Fix: remove the first duplicate emission and compute total_prompt_tokens
as the sum of all three token types. cache_hit_rate is now a proper 0-1
ratio.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: emit tool call id/name from tool-input-start in Vercel stream converter

The Vercel AI SDK streams tool calls as tool-input-start → tool-input-delta
→ tool-input-end → tool-call. Previously, tool-input-start was ignored (returned
null) and tool-call emitted the full tool call at the end, which meant streaming
consumers never saw the tool call id on intermediate chunks.

Now tool-input-start emits the initial chunk with id and function name (matching
OpenAI's streaming format), and tool-call returns null to avoid duplicating args
already streamed via tool-input-delta.

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Continue <noreply@continue.dev>
2026-03-04 07:57:41 -08:00
..
cli fix: correct cache_hit_rate calculation and fix Vercel stream tool call handling (#10994) 2026-03-04 07:57:41 -08:00
intellij docs: remove tagline description from all READMEs 2026-02-16 18:44:34 -08:00
vscode feat: add Claude Sonnet 4.6 and Claude Opus 4.6 models 2026-02-17 11:49:21 -08:00