mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
bc0c3fcd63
* fix(agents): cancel rejected provider binary bodies * refactor(providers): share generated media downloads * refactor(providers): adopt payload patch stream wrapper * fix(providers): preserve generated media helper contracts
23 lines
901 B
TypeScript
23 lines
901 B
TypeScript
// Deepinfra plugin module implements cache wrapper behavior.
|
|
import type { StreamFn } from "openclaw/plugin-sdk/agent-core";
|
|
import {
|
|
applyAnthropicEphemeralCacheControlMarkers,
|
|
createPayloadPatchStreamWrapper,
|
|
} from "openclaw/plugin-sdk/provider-stream-shared";
|
|
|
|
// Inject Anthropic ephemeral cache_control markers for anthropic/* models on
|
|
// DeepInfra. The OpenRouter equivalent short-circuits on a provider/endpoint
|
|
// check, so DeepInfra advertises isCacheTtlEligible but the payload patch
|
|
// never fires. Gating on the model id instead fixes that.
|
|
export function createDeepInfraAnthropicCacheWrapper(baseStreamFn: StreamFn): StreamFn {
|
|
return createPayloadPatchStreamWrapper(
|
|
baseStreamFn,
|
|
({ payload }) => {
|
|
applyAnthropicEphemeralCacheControlMarkers(payload);
|
|
},
|
|
{
|
|
shouldPatch: ({ model }) => model.id.toLowerCase().startsWith("anthropic/"),
|
|
},
|
|
);
|
|
}
|