symfonic.capabilities.prompting.strategies¶
strategies ¶
The two context strategies, as declarations rather than code paths.
jit builds a lean prompt from what is already known: nothing is hydrated,
and nothing is cached, because a prompt assembled per turn from a different
subset has no stable prefix to cache. stratified admits hydrated context
and caches the stable layers, which is the shape prompt caching was designed
for.
The important property is that the strategy is a pair of pure functions over a contribution, not two compilers. One pipeline compiles both strategies, so a change to ordering, gating, or budgeting cannot land on one of them and miss the other — the failure mode a second builder always eventually produces.
ContextStrategy ¶
Bases: StrEnum
How much context the compiler assembles, and whether it may be cached.
cache_directive_for ¶
The cache annotation this contribution carries under strategy.
JIT caches nothing — including a contribution that declared a directive,
since a prefix that changes shape per turn cannot be a cache hit and the
breakpoint would be pure cost. Under stratified a declared directive
wins, and the default is derived from volatility: stable layers cache at
the provider's default tier, the volatile layer never does.
Source code in src/symfonic/capabilities/prompting/strategies.py
resolve_strategy ¶
Resolve the strategy from an explicit name, falling back to the legacy flag.
Precedence is stated once, here, so the facade and the compiler cannot disagree about which strategy a given configuration selects — the classic "two factories, two answers" defect.
Source code in src/symfonic/capabilities/prompting/strategies.py
strategy_admits ¶
True when strategy assembles this contribution at all.
The only axis is hydration: JIT declines contributions whose content only exists after a retrieval pass, because performing that pass is exactly what JIT exists to avoid.