symfonic.capabilities.caching¶
caching ¶
Native Anthropic request-cache composition.
The public values in this module configure the native agent's request shape. They do not turn on a process-local transcript cache: history remains caller owned and is composed afresh for every invocation.
HistoryCacheComposer ¶
Annotate the latest completed text turn without retaining transcript state.
Source code in src/symfonic/capabilities/caching/composition.py
compose ¶
Return a fresh wire-message list with one safe history marker.
Only closed user messages and assistant messages without pending tools can carry the marker. Tool-result exchanges are deliberately skipped: the facade's typed transcript does not retain the provider's original tool-use blocks, so claiming a cache point inside that reconstructed exchange would be speculative. A preceding ordinary user turn is still a valid conservative boundary.
Source code in src/symfonic/capabilities/caching/composition.py
HistoryCachePolicy
dataclass
¶
The marker policy for completed native conversation history.
enabled=False is a hard off switch: no message is reshaped and no
cache-control field is emitted. The default five-minute marker is the
canonical Anthropic wire spelling; the optional one-hour tier is explicit.
ManifestCachePolicy
dataclass
¶
ManifestCachePolicy(enabled: bool = True, position: ManifestCachePosition = ManifestCachePosition.CACHED, ttl: CacheTtl = CacheTtl.FIVE_MINUTES)
The marker policy for the provider's bound native tool schemas.
ManifestCachePosition ¶
Bases: StrEnum
Whether the native bound-tool manifest receives an Anthropic marker.
CACHED stamps the final Anthropic tool definition, so the preceding
definitions participate in that request's cache prefix. VOLATILE
binds exactly the same native tools without a marker. It intentionally
does not claim the legacy JIT text-manifest split: native tools are schemas
on the provider request, not text inserted into a legacy prompt template.
NativeCacheComposition
dataclass
¶
NativeCacheComposition(history: HistoryCachePolicy = HistoryCachePolicy(), manifest: ManifestCachePolicy = ManifestCachePolicy())
Opt-in native history and tool-manifest request-cache composition.
Pass one instance in Agent(capabilities=[...]). The composition is
valid only for adapters that actually send the Anthropic Messages API
cache_control dialect. Unsupported providers are refused while a
marker is requested; this avoids accepting a configuration that silently
does nothing on a different wire protocol.
contribute ¶
Join the capability fold without adding a kernel stage.
The policy is executed at the provider adapter seams, after the kernel has assembled the precise message and tool values. A stage would be too early for both serializer-specific operations.
Source code in src/symfonic/capabilities/caching/composition.py
require_supported_provider ¶
Refuse cache annotation where the transport cannot honour it.
Source code in src/symfonic/capabilities/caching/composition.py
ToolManifestBinder ¶
Bind native tools and, when requested, mark the Anthropic tool manifest.
Source code in src/symfonic/capabilities/caching/composition.py
bind ¶
Bind the exact tool sequence handed to this plan or palette.
Conversion occurs before bind_tools because LangChain Anthropic
preserves cache_control only on an already-Anthropic schema. A
changed palette is converted anew, so it cannot reuse a prior
manifest's mutable dictionary or inherit its marker by accident.