mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 08:41:23 +00:00
fix(providers): disable Bedrock prompt caching for non-Anthropic models (#20866) (thanks @pierreeurope)
This commit is contained in:
@@ -151,6 +151,42 @@ describe("applyExtraParamsToAgent", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("disables prompt caching for non-Anthropic Bedrock models", () => {
|
||||
const { calls, agent } = createOptionsCaptureAgent();
|
||||
|
||||
applyExtraParamsToAgent(agent, undefined, "amazon-bedrock", "amazon.nova-micro-v1");
|
||||
|
||||
const model = {
|
||||
api: "openai-completions",
|
||||
provider: "amazon-bedrock",
|
||||
id: "amazon.nova-micro-v1",
|
||||
} as Model<"openai-completions">;
|
||||
const context: Context = { messages: [] };
|
||||
|
||||
void agent.streamFn?.(model, context, {});
|
||||
|
||||
expect(calls).toHaveLength(1);
|
||||
expect(calls[0]?.cacheRetention).toBe("none");
|
||||
});
|
||||
|
||||
it("keeps Anthropic Bedrock models eligible for provider-side caching", () => {
|
||||
const { calls, agent } = createOptionsCaptureAgent();
|
||||
|
||||
applyExtraParamsToAgent(agent, undefined, "amazon-bedrock", "us.anthropic.claude-sonnet-4-5");
|
||||
|
||||
const model = {
|
||||
api: "openai-completions",
|
||||
provider: "amazon-bedrock",
|
||||
id: "us.anthropic.claude-sonnet-4-5",
|
||||
} as Model<"openai-completions">;
|
||||
const context: Context = { messages: [] };
|
||||
|
||||
void agent.streamFn?.(model, context, {});
|
||||
|
||||
expect(calls).toHaveLength(1);
|
||||
expect(calls[0]?.cacheRetention).toBeUndefined();
|
||||
});
|
||||
|
||||
it("adds Anthropic 1M beta header when context1m is enabled for Opus/Sonnet", () => {
|
||||
const { calls, agent } = createOptionsCaptureAgent();
|
||||
const cfg = buildAnthropicModelConfig("anthropic/claude-opus-4-6", { context1m: true });
|
||||
|
||||
Reference in New Issue
Block a user