continue-custom/packages
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
..
config-types fix: upgrade zod from 3.24.2 to 3.25.76 2025-11-04 07:18:35 +00:00
config-yaml feat: add Claude Sonnet 4.6 and Claude Opus 4.6 models 2026-02-17 11:49:21 -08:00
continue-sdk fix: packages/continue-sdk/package.json & packages/continue-sdk/package-lock.json to reduce vulnerabilities 2026-02-11 10:54:29 +00:00
fetch chore(deps-dev): bump lodash from 4.17.21 to 4.17.23 in /packages/fetch 2026-01-26 00:14:33 +00:00
hub chore: continue package bumps (#9532) 2026-01-14 11:31:41 -08:00
llm-info feat: model updates and + z.ai (#10638) 2026-02-20 00:35:44 -08:00
openai-adapters fix: correct cache_hit_rate calculation and fix Vercel stream tool call handling (#10994) 2026-03-04 07:57:41 -08:00
terminal-security style: run prettier on terminal security code 2025-10-30 00:56:55 +00:00
shared-release.config.js fix prettier 2025-07-18 19:20:13 +02:00