MCPcopy
hub / github.com/coder/mux / createCachedSystemMessage

Function createCachedSystemMessage

src/common/utils/ai/cacheStrategy.ts:122–136  ·  view source on GitHub ↗
(
  systemContent: string,
  modelString: string,
  cacheTtl?: AnthropicCacheTtl | null
)

Source from the content-addressed store, hash-verified

120 * System messages rarely change and should always be cached.
121 */
122export function createCachedSystemMessage(
123 systemContent: string,
124 modelString: string,
125 cacheTtl?: AnthropicCacheTtl | null
126): ModelMessage | null {
127 if (!systemContent || !supportsAnthropicCache(modelString)) {
128 return null;
129 }
130
131 return {
132 role: "system" as const,
133 content: systemContent,
134 providerOptions: cacheTtl ? anthropicCacheControl(cacheTtl) : ANTHROPIC_CACHE_CONTROL,
135 };
136}
137
138/**
139 * Apply cache control to tool definitions for Anthropic models.

Callers 2

Calls 2

supportsAnthropicCacheFunction · 0.85
anthropicCacheControlFunction · 0.85

Tested by

no test coverage detected