You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 8, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 8, 2026. It is now read-only.
agent memory: structured truncated tool_result on the wire (not Tool: crumbs) #549
formatPromptWithHistorydrops every tool_run row (lib/sessionStore.ts).
Those cards are display-only (plan #345). The model already saw tool results this turn; on the next turn it gets only user/assistant/system/error
prose, flattened into one { prompt } string.
Operators see: the agent re-reads the same files, forgets what it grepped,
never builds session memory, and talks like a new hire each send.
We persist up to 8 MiB of those cards in Blob/localStorage and then omit them from inference.
Goal (locked direction)
Put truncated tool_result on the wire as structured messages — not Tool: … lines stuffed into formatPromptWithHistory.
Peer harnesses (OpenCode / Pi / Oh My Pi) send a real message array:
user / assistant + tool_use / tool_result (thinking only if the
provider wants it). That is how the next turn still knows what was read.
Success: after a turn that read_files / greps / change_dirs, the next
user message can be “use what you already found” and the model does not
rediscover the tree from zero.
How (directional — lock in create-plan)
Host/server keep a model-facing trace (call id, name, args, truncated
result, ok) distinct from the Wasm paint card (tool_run stays
display-primary).
Default send: bounded result (paths + status + short excerpt). OpenCode
~2k lines / 50 KB; Pi ~2k chars at compact time. Do not re-send TOOL_RUN_PREVIEW_MAX_CHARS (100k) per item.
Prefer AI SDK / Gateway native tool-result messages over a flattened
transcript. Flattening is a fallback if a provider cannot take the array —
still truncated, still paired (never a call without its result).
Abort/cancel: persist committed tools the same way we persist change_dir
(honest, not a hallucinated summary of a cancelled mid-tool).
Constraints (lock)
Wasm ring / tool_runpaint stays display-primary (feature-divide).
Hygiene: few summary lines in the model-facing result; verbose exec/test output stays on the sandbox disk (file path in the result). Same Anthropic “parallel Claudes” lesson as their exec tool. Caps for that excerpt land in the A1 create-plan table — do not default to TOOL_RUN_PREVIEW_MAX_CHARS.
Parent
#548 (agent session architecture)
Problem
formatPromptWithHistorydrops everytool_runrow (lib/sessionStore.ts).Those cards are display-only (plan #345). The model already saw tool results
this turn; on the next turn it gets only user/assistant/system/error
prose, flattened into one
{ prompt }string.Operators see: the agent re-reads the same files, forgets what it grepped,
never builds session memory, and talks like a new hire each send.
We persist up to 8 MiB of those cards in Blob/
localStorageand thenomit them from inference.
Goal (locked direction)
Put truncated
tool_resulton the wire as structured messages — notTool: …lines stuffed intoformatPromptWithHistory.Peer harnesses (OpenCode / Pi / Oh My Pi) send a real message array:
user/assistant+tool_use/tool_result(thinking only if theprovider wants it). That is how the next turn still knows what was read.
Invincible today: single-shot
{ prompt }+ display-onlytool_run.Success: after a turn that
read_files /greps /change_dirs, the nextuser message can be “use what you already found” and the model does not
rediscover the tree from zero.
How (directional — lock in create-plan)
result, ok) distinct from the Wasm paint card (
tool_runstaysdisplay-primary).
~2k lines / 50 KB; Pi ~2k chars at compact time. Do not re-send
TOOL_RUN_PREVIEW_MAX_CHARS(100k) per item.transcript. Flattening is a fallback if a provider cannot take the array —
still truncated, still paired (never a call without its result).
change_dir(honest, not a hallucinated summary of a cancelled mid-tool).
Constraints (lock)
tool_runpaint stays display-primary (feature-divide).in a future
create-planCaps table; changing 3.5M / 400 is inference budget: replace 400-row / 3.5M-char fold with model-window token budget #551.Peer harness notes
tool_use/tool_resultin the messages arrayNon-goals
Suggested next
create-planagainst #548 A1 before coding.Orrery (2026-08-15)
exectool. Caps for that excerpt land in the A1create-plantable — do not default toTOOL_RUN_PREVIEW_MAX_CHARS.model → tools → system → historyis locked before the request is built (inference: cache-stable two-block system prompt (don’t bust the KV prefix) #558). Structured messages are the history part, not a second system dump.Related tools (not this board)
Tool-side shaping (so there is something honest to fold):
searchread_filestr_replacewindowexecsummary + disk logThose issues are sandbox/tools, not agent-session. This issue remains structured
tool_resulton the wire.