Use setEncoding("utf8") on stdout/stderr streams instead of
per-chunk Buffer.toString() to avoid breaking multi-byte characters
at chunk boundaries.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move execa type import before vitest to satisfy eslint import/order.
Require SMOKE_PROXY_MODEL env var for continue-proxy test since the
proxy needs a 4-part model name (owner/package/provider/model) that
depends on org-specific configuration.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a new smoke-api test suite that proves the CLI can complete real LLM
round-trips against the Anthropic API. Tests cover headless mode,
serve mode, and all-tools execution. Runs sequentially to avoid rate
limits, skips gracefully when API keys are missing (fork PRs), and
is wired into CI as a required check with allowed-skips.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add --provenance flag to npm publish so it uses the GitHub OIDC token
exchange instead of the expired NODE_AUTH_TOKEN for authentication.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Skip addCacheControlToLastTwoUserMessages when cachingStrategy is "none"
so requests truly have no caching markers. Updates test to verify.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add required `provider: "anthropic"` to AnthropicApi constructor calls
and use `(textPart as any)` type assertion for `cache_control` property
access, which is dynamically added and not in the ContentBlockParam type.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove the getDirectoryStructure() function and its embedding in the
system prompt. This was walking up to 500 files and embedding them as a
static tree in every API request, adding ~3,500-5,000 tokens per call.
The LLM already has tools (listFiles, Glob, Grep) to discover files on
demand, making the embedded tree redundant. Claude Code does not include
directory structure in its system prompt for the same reason.
This also improves prompt cache hit rates since the system prompt no
longer varies by project directory contents.
Generated with [Continue](https://continue.dev)
Co-Authored-By: Continue <noreply@continue.dev>
Cache the last two user messages in _convertBody() by calling
addCacheControlToLastTwoUserMessages() after applying the caching
strategy. This brings the direct Anthropic path to parity with
OpenRouter, which already caches user messages.
Caching the last two user messages allows Anthropic to serve ~90%
of those tokens from cache reads at 1/10th the cost, significantly
reducing per-request input token costs for multi-turn conversations.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add cacheReadTokens and cacheWriteTokens to the existing apiRequest
PostHog event, and emit a new prompt_cache_metrics event with
cache_hit_rate, cache_read_tokens, cache_write_tokens,
total_prompt_tokens, tool_count, and model. This populates the
existing Prompt Cache Performance dashboard (ID: 1310089).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Preserve Vitest's default excludes (dist, node_modules, etc.) when
adding the live test exclusion pattern.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Live test files (*.live.test.ts) make real Anthropic API calls and are
intended for manual validation only. Exclude them from the default
vitest configuration to prevent flaky CI failures.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Clone message content blocks before mutating for cache_control
(prevents mutation of original input body)
- Add `void` prefix to async posthogService.capture call
- Fix duplicate assistant messages in Scenario 3 test loop
- Add unit test verifying original body is not mutated
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The systemAndTools caching strategy now adds cache_control to the last
two user messages via addCacheControlToLastTwoUserMessages(). Update
existing test expectations to include the cache_control field.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The OpenAI PromptTokensDetails type doesn't include cache_read_tokens
(it's an Anthropic extension). Add 'as any' casts to fix TypeScript
build errors in the battle test file.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
7 distinct scenarios covering tool use round-trips, parallel tool calls,
long 8-turn conversations, large tool results (~200 lines), cache
invalidation on system message changes, identical request replays, and
multi-step agentic workflows with chained tool calls.
All scenarios validate cache hit rates >90% where expected and proper
cache misses when the system message changes.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add addCacheControlToLastTwoUserMessages call in systemAndToolsStrategy
so the CLI path caches conversation turns (matching VS Code extension behavior)
- Report prompt_cache_metrics to PostHog with cache_read/write tokens and hit rate
- Add live API integration test validating cache writes on turn 1 and 99%+ hit
rates on subsequent turns (guarded by ANTHROPIC_API_KEY env var)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>