Files
Peter Steinberger bc0c3fcd63 refactor(providers): shared generated-media download guard and binary-response adoption (#120351)
* 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
2026-08-07 15:45:53 -07:00

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/"),
},
);
}