Skip to content

Commit fb85a4d

Browse files
committed
fix: extend resolveCacheRetention to pass through cacheRetention for amazon-bedrock
The runtime resolveCacheRetention hard-gates on provider === "anthropic" and returns undefined for amazon-bedrock, so cacheRetention set in model params is never consumed at runtime for Bedrock models. Extend the gate to also accept amazon-bedrock when cacheRetention is explicitly configured. No default is applied for Bedrock since pi-ai own provider already defaults to "short" internally. Refs #21986
1 parent a0d636b commit fb85a4d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/agents/pi-embedded-runner/extra-params.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,20 @@ type CacheRetentionStreamOptions = Partial<SimpleStreamOptions> & {
4242
*
4343
* Mapping: "5m" → "short", "1h" → "long"
4444
*
45-
* Only applies to Anthropic provider (OpenRouter uses openai-completions API
46-
* with hardcoded cache_control, not the cacheRetention stream option).
45+
* Only applies to Anthropic provider and Anthropic Claude models on Bedrock.
46+
* (OpenRouter uses openai-completions API with hardcoded cache_control,
47+
* not the cacheRetention stream option).
4748
*
48-
* Defaults to "short" for Anthropic provider when not explicitly configured.
49+
* Defaults to "short" for Anthropic when not explicitly configured.
4950
*/
5051
function resolveCacheRetention(
5152
extraParams: Record<string, unknown> | undefined,
5253
provider: string,
5354
): CacheRetention | undefined {
54-
if (provider !== "anthropic") {
55+
const isAnthropicDirect = provider === "anthropic";
56+
const isAnthropicBedrock =
57+
provider === "amazon-bedrock" && extraParams?.cacheRetention !== undefined;
58+
if (!isAnthropicDirect && !isAnthropicBedrock) {
5559
return undefined;
5660
}
5761

0 commit comments

Comments
 (0)