feat: add prompt caching + upgrade @anthropic-ai/sdk to 0.91.1#237
Open
feat: add prompt caching + upgrade @anthropic-ai/sdk to 0.91.1#237
Conversation
- Enable ephemeral prompt caching on system prompts in callClaude() and streamClaude() — reduces latency and cost on repeated pipeline runs that reuse the same large system prompt - Log cache_read_input_tokens / cache_creation_input_tokens at debug level so users can see caching savings - Bump @anthropic-ai/sdk ^0.32.0 → ^0.91.1 to get proper TypeScript types for cache_control on TextBlockParam and UsageCacheStats - Fix pre-existing Ajv.default() instantiation bug in stages.ts (ESM default import was incorrectly double-dereferenced)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
callClaude()andstreamClaude()are now marked withcache_control: { type: 'ephemeral' }, enabling Anthropic's prompt caching for all API calls that pass a system prompt@anthropic-ai/sdkbumped from^0.32.0→^0.91.1— the old version lacked TypeScript types forcache_controlonTextBlockParamandcache_read_input_tokens/cache_creation_input_tokensonUsagenew Ajv.default()instages.tswas incorrectly double-dereferencing the ESM default export — changed tonew Ajv()(pre-existing bug)Why
AppFactory pipeline runs pass large system prompts (stage templates, standards files) on every Claude call. Without caching, each call pays full input-token cost for the same repeated context. With ephemeral caching enabled:
Tested
npm run type-check:cli— passes clean (0 errors)npm run test:unit— 159/159 tests pass🤖 Generated with Claude Code