MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / _cached_text

Function _cached_text

openkb/agent/compiler.py:263–274  ·  view source on GitHub ↗

Wrap a text payload into a content-block list with an Anthropic ephemeral cache_control marker. LiteLLM passes the marker through to Anthropic (and OpenRouter → Anthropic). For other providers the marker is stripped at the request egress (see :func:`_strip_cache_control`, applied in

(text: str)

Source from the content-addressed store, hash-verified

261
262
263def _cached_text(text: str) -> list[dict]:
264 """Wrap a text payload into a content-block list with an Anthropic
265 ephemeral cache_control marker.
266
267 LiteLLM passes the marker through to Anthropic (and OpenRouter →
268 Anthropic). For other providers the marker is stripped at the request
269 egress (see :func:`_strip_cache_control`, applied in :func:`_llm_call`),
270 because not every provider merely *ignores* it — Gemini in particular
271 turns it into a 400. The list-of-blocks payload that remains is a valid
272 OpenAI-compatible content shape.
273 """
274 return [{"type": "text", "text": text, "cache_control": {"type": "ephemeral"}}]
275
276
277def _accepts_cache_control(model: str) -> bool:

Calls

no outgoing calls