feat: add Bedrock prompt cache TTL config#12875
feat: add Bedrock prompt cache TTL config#12875SharpLu wants to merge 1 commit intodanny-avila:mainfrom
Conversation
44d18ec to
96286dd
Compare
There was a problem hiding this comment.
Pull request overview
Adds an optional Bedrock prompt-cache checkpoint TTL configuration (5m or 1h) that can be set via endpoints.bedrock.promptCacheTtl, validates it, threads it through Bedrock initialization, and ensures stale TTL values are stripped when prompt caching is disabled/unsupported.
Changes:
- Extend conversation/preset types + schemas to allow
promptCacheTtl: '5m' | '1h'. - Add Bedrock endpoint config validation for
promptCacheTtland pass it into BedrockllmConfig. - Normalize Bedrock prompt-cache options to preserve TTL only for Claude/Nova models and strip TTL when promptCache is false/unsupported; add tests + document YAML option.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/data-schemas/src/types/convo.ts | Adds promptCacheTtl to conversation TS typing. |
| packages/data-schemas/src/schema/preset.ts | Adds promptCacheTtl to preset TS typing. |
| packages/data-schemas/src/schema/defaults.ts | Adds Mongoose schema enum for promptCacheTtl. |
| packages/data-provider/src/types.ts | Allows promptCacheTtl in endpoint option typing surface. |
| packages/data-provider/src/schemas.ts | Accepts promptCacheTtl in conversation/query validation schemas. |
| packages/data-provider/src/config.ts | Validates Bedrock endpoint config promptCacheTtl (5m/1h). |
| packages/data-provider/src/config.spec.ts | Tests Bedrock endpoint schema accepts/rejects TTL values. |
| packages/data-provider/src/bedrock.ts | Normalizes prompt cache + TTL behavior for supported models and strips stale TTL. |
| packages/data-provider/specs/bedrock.spec.ts | Adds tests for preserving/stripping promptCacheTtl behavior. |
| packages/api/src/types/bedrock.ts | Adds BedrockPromptCacheTtl type + config fields. |
| packages/api/src/endpoints/bedrock/initialize.ts | Threads endpoint-config TTL into Bedrock request/llmConfig. |
| packages/api/src/endpoints/bedrock/initialize.spec.ts | Tests promptCacheTtl is present only when configured. |
| librechat.example.yaml | Documents the new endpoints.bedrock.promptCacheTtl option. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| promptCache: z.boolean().optional(), | ||
| promptCacheTtl: z.enum(['5m', '1h']).optional(), |
There was a problem hiding this comment.
promptCacheTtl is documented as part of the /* Anthropic */ block, but this TTL is Bedrock-specific (per PR description and usage in bedrockInputParser). This comment/section placement is misleading; please either move promptCacheTtl to the AWS Bedrock section of the schema or update the comment to reflect Bedrock usage.
| promptCache: z.boolean().optional(), | |
| promptCacheTtl: z.enum(['5m', '1h']).optional(), | |
| promptCache: z.boolean().optional(), | |
| /* AWS Bedrock */ | |
| promptCacheTtl: z.enum(['5m', '1h']).optional(), | |
| /* Anthropic */ |
| // Anthropic-specific | ||
| | 'promptCache' | ||
| | 'promptCacheTtl' |
There was a problem hiding this comment.
promptCacheTtl is listed under the // Anthropic-specific grouping, but it's Bedrock-only (whereas promptCache applies to both Anthropic and Bedrock). Please adjust the grouping/comment so future readers don’t assume this option is supported by the Anthropic endpoint.
| // Anthropic-specific | |
| | 'promptCache' | |
| | 'promptCacheTtl' | |
| // Anthropic/Bedrock | |
| | 'promptCache' | |
| // Bedrock-specific | |
| | 'promptCacheTtl' | |
| // Anthropic-specific |
| /* Anthropic only */ | ||
| promptCache: { | ||
| type: Boolean, | ||
| }, | ||
| promptCacheTtl: { | ||
| type: String, | ||
| enum: ['5m', '1h'], | ||
| }, |
There was a problem hiding this comment.
The new promptCacheTtl field is placed under the /* Anthropic only */ section, but the TTL is Bedrock-specific. This comment/section placement is misleading; please move promptCacheTtl to a Bedrock section (or rename the comment to reflect shared/Bedrock usage).
96286dd to
9835757
Compare
9835757 to
e5ff82f
Compare
|
Hey @danny-avila, friendly bump on this one — just rebased onto main, CI is green. The PR adds an optional Depends on danny-avila/agents#123 (also rebased now) for the runtime side. Happy to address any feedback whenever you have a moment. Thanks! |
Summary
Bedrock prompt caching now supports both 5-minute and 1-hour cache checkpoint TTLs. This PR adds an optional
endpoints.bedrock.promptCacheTtlYAML config so LibreChat admins can choose5mor1h; when the setting is omitted, LibreChat does not send a TTL and Bedrock keeps the existing 5-minute default behavior.This is useful for longer Bedrock/Claude sessions where users reuse large system prompts, tools, or reference context across turns that may be more than five minutes apart. The 1-hour TTL lets supported Bedrock Claude 4.5 models retain those cache checkpoints longer when the admin explicitly opts in.
Changes
promptCacheTtl: "5m" | "1h"promptCacheTtlfromlibrechat.yamlinto BedrockllmConfig1honly for Claude 4.5 Bedrock model IDs, and strip stale/unsupported TTL values so unsupported models fall back to Bedrock default 5-minute behavior5mfor prompt-cache-supported Claude/Nova modelslibrechat.example.yamland the HelmconfigYamlContentexampleDeployment configuration
Docker/Compose users can set this in the mounted
librechat.yamlfile. Helm users can set the same YAML underlibrechat.configYamlContent, or provide an existing ConfigMap throughlibrechat.existingConfigYamlwith alibrechat.yamlkey.References
cachePoint.ttl: feat: support Bedrock prompt cache TTL agents#123Testing
cd packages/data-provider && npx jest specs/bedrock.spec.ts src/config.spec.ts --runInBand --coverage=falsenpm run build:data-providercd packages/api && npx jest src/endpoints/bedrock/initialize.spec.ts --runInBand --coverage=falsenpm run build:data-schemashelm lint helm/librechathelm template bedrock-test helm/librechat -f <values-with-bedrock-promptCacheTtl.yaml>docker compose -f docker-compose.yml -f docker-compose.override.yml configdocker compose -f deploy-compose.yml configgit diff --check