Skip to content

symfonic.capabilities.tools.results.policy

policy

The result policy — one decision, one reason (T3.1.3).

The compaction rewriter used to interleave six early returns with the rewrite itself, so the decision could only be observed through the transcript it produced. Separating them makes each branch assertable on its own and gives every kept payload a stated cause.

Branch order is load-bearing and reads top to bottom:

  1. disabled — nothing happens at all;
  2. multimodal — the result carries a block the model looks at rather than reads. Every rewrite below replaces content with text, and recall returns str, so rewriting one converts evidence into a description of evidence. Ranked above recent deliberately: a recent image is kept for both reasons and the stated one should be the safety property, because that is the one whose absence would be a defect (#144);
  3. recent — the last keep_last_n results are the model's working set;
  4. below threshold — too small to be worth a stub;
  5. offload only: live turn — the result is inside the current turn's tool loop, so moving it would shift bytes mid-turn and bust the messages-region cache. This is the v7.12.1 +94.8% regression;
  6. offload only: below the large pre-filter — small enough that the expected recall hop outweighs the re-prefill saving;
  7. offload only: the net-saving gate — offload fires only when it provably saves money.

A gate that raises, or no gate at all, declines. Firing offload wrongly is precisely the failure the gate exists to prevent.

ResultPolicy

ResultPolicy(settings: ResultPolicySettings, *, net_saving_gate: NetSavingGate | None = None)

Decide what happens to one settled tool result.

Source code in src/symfonic/capabilities/tools/results/policy.py
def __init__(
    self,
    settings: ResultPolicySettings,
    *,
    net_saving_gate: NetSavingGate | None = None,
) -> None:
    self._settings = settings
    self._gate = net_saving_gate

for_settings

for_settings(settings: ResultPolicySettings) -> ResultPolicy

A policy over the same gate with different settings.

Source code in src/symfonic/capabilities/tools/results/policy.py
def for_settings(self, settings: ResultPolicySettings) -> ResultPolicy:
    """A policy over the same gate with different settings."""
    return ResultPolicy(settings, net_saving_gate=self._gate)