mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 19:58:27 +00:00
fix(providers): disable Bedrock prompt caching for non-Anthropic models (#20866) (thanks @pierreeurope)
This commit is contained in:
@@ -137,6 +137,20 @@ function createStreamFnWithExtraParams(
|
||||
return wrappedStreamFn;
|
||||
}
|
||||
|
||||
function isAnthropicBedrockModel(modelId: string): boolean {
|
||||
const normalized = modelId.toLowerCase();
|
||||
return normalized.includes("anthropic.claude") || normalized.includes("anthropic/claude");
|
||||
}
|
||||
|
||||
function createBedrockNoCacheWrapper(baseStreamFn: StreamFn | undefined): StreamFn {
|
||||
const underlying = baseStreamFn ?? streamSimple;
|
||||
return (model, context, options) =>
|
||||
underlying(model, context, {
|
||||
...options,
|
||||
cacheRetention: "none",
|
||||
});
|
||||
}
|
||||
|
||||
function isDirectOpenAIBaseUrl(baseUrl: unknown): boolean {
|
||||
if (typeof baseUrl !== "string" || !baseUrl.trim()) {
|
||||
return true;
|
||||
@@ -501,6 +515,11 @@ export function applyExtraParamsToAgent(
|
||||
agent.streamFn = createOpenRouterSystemCacheWrapper(agent.streamFn);
|
||||
}
|
||||
|
||||
if (provider === "amazon-bedrock" && !isAnthropicBedrockModel(modelId)) {
|
||||
log.debug(`disabling prompt caching for non-Anthropic Bedrock model ${provider}/${modelId}`);
|
||||
agent.streamFn = createBedrockNoCacheWrapper(agent.streamFn);
|
||||
}
|
||||
|
||||
// Enable Z.AI tool_stream for real-time tool call streaming.
|
||||
// Enabled by default for Z.AI provider, can be disabled via params.tool_stream: false
|
||||
if (provider === "zai" || provider === "z-ai") {
|
||||
|
||||
Reference in New Issue
Block a user