symfonic.capabilities.tools.results¶
results ¶
Result-policy capability โ compaction, offload, recall (T3.1.3).
What happens to a tool result after the tool returns used to be three
unrelated shapes: a hundred-line rewriter inside the react node, a pure
pricing function in core/, and a framework tool in tools/. They
implement one policy โ a result is kept, compacted into a deterministic
stub, or offloaded once offload provably saves money, and whatever left
the wire must be reachable again on the model's initiative.
Three objects state that policy:
- :class:
ResultPolicydecides, and every decision carries its reason; - :class:
ResultPolicyServiceapplies decisions to a transcript under the id-preservation, immutability and determinism invariants; - :class:
RecallServicebrings a payload back without ever raising into the tool-invocation path.
The capability imports nothing but its own package: the provider message type and the pricing gate are both injected.
RecallService ¶
ResultDecision
dataclass
¶
The disposition and the one-word reason behind it.
The reason is the deliverable. "Why is this 200KB payload still on the wire?" used to require reading a hundred-line rewriter with six early returns; it is now a string.
ResultDisposition ¶
Bases: StrEnum
What happens to one settled tool result.
ResultPolicy ¶
Decide what happens to one settled tool result.
Source code in src/symfonic/capabilities/tools/results/policy.py
for_settings ¶
A policy over the same gate with different settings.
ResultPolicyService ¶
Rewrite the wire view of a transcript according to the policy.
Source code in src/symfonic/capabilities/tools/results/service.py
last_decisions
property
¶
What the most recent :meth:apply decided, per result.
apply
async
¶
apply(messages: Sequence[Any], *, start_index: int = 0, fresh_start_index: int | None = None) -> list[Any]
Return the wire view of messages.
Returns the argument itself (identity, not a copy) when nothing
can change โ which is every iteration of every deployment that
leaves compaction off. start_index leaves replayed history full:
its call IDs can repeat in this invocation, while its payloads do not
belong to the invocation ledger. fresh_start_index protects recall
outputs only until their first model exposure.
Source code in src/symfonic/capabilities/tools/results/service.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
ResultPolicySettings
dataclass
¶
ResultPolicySettings(enabled: bool = False, size_chars: int = DEFAULT_SIZE_THRESHOLD_CHARS, keep_last_n: int = 1, offload_enabled: bool = False, large_offload_threshold_chars: int = DEFAULT_LARGE_OFFLOAD_THRESHOLD_CHARS, turn_boundary_index: int | None = None, model_name: str = '', expected_conversation_depth: int = 5, expected_recall_probability: float = 0.5)
Everything the policy needs to decide, read once.
enabled defaults to False. v8.7.1 (C1): the pre-T3.1.3
fallback used to default it True, so a dropped config key silently
force-enabled compaction and pointed recall stubs at an unregistered
recall tool โ the payload was simply gone.
with_turn_boundary ¶
A copy carrying a derived boundary, when the caller had none.
Source code in src/symfonic/capabilities/tools/results/values.py
ResultRecord
dataclass
¶
ResultRecord(call_id: str, tool_name: str, size_chars: int, decision: ResultDecision, applied: bool = False)
One decision, attributed to the call it was made about.
Transcript ¶
Bases: Protocol
The narrow slice of a message transcript the service reads.