symfonic.tools.recall_tool_result¶
recall_tool_result ¶
recall_tool_result: framework tool for re-expanding compacted tool results.
v7.12.0 ships ToolResultLedger which swaps verbose ToolMessage
content for a compact stub on every react iteration past the keep_last_n
threshold. The stub embeds a mem_id (trm_*) the model can pass to
this tool to recover the original payload at full or summary fidelity.
Architectural contract¶
- Framework provides the tool; model authors the args. The v7.8.3 architectural-line guard: the framework constrains the choice set (we register this tool), the model decides when to recall, which mem_id to expand, and at what fidelity.
- Side-effect-free. Calling
recall_tool_resultonly reads from the ledger. It does not write or mutate state. - Defensive on bad input. An LLM that hallucinates a mem_id (or types one with a typo) gets a structured "not found" message, not an exception. The framework MUST NOT raise into the tool invocation path -- the model has to be able to recover.
- Bounded output.
MAX_OUTPUT_CHARScaps the recall payload at 50KB so a single 5MB tool result can't blow the next iteration's context window. This is defense-in-depth alongside the v7.12.0 compaction itself.
Recipe (engine registration)::
from symfonic.tools.recall_tool_result import create_recall_tool_result_tool
tool = create_recall_tool_result_tool(ledger=agent._deps.require(ToolResultLedger))
agent._graph.registry.register_runtime_tool(tool)
create_recall_tool_result_tool ¶
Build the recall_tool_result LangChain tool bound to a
specific :class:ToolResultLedger instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ledger
|
Any
|
A registered :class: |
required |
Returns:
| Type | Description |
|---|---|
Any
|
An |
Any
|
|
Source code in src/symfonic/tools/recall_tool_result.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 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 | |