Parent
#548 (agent session architecture)
Problem
The only “compaction” we have is drop oldest rows and slice the
string. That is an API-payload habit. Other harnesses (Pi
CompactionEntry + retainedTail; OpenCode summary parts) compact to
the model window and keep a checkpoint so they do not re-walk the entire
log.
We need that for intelligence, independent of how Blob is paged.
Goal
A compaction mechanism keyed on model capability (A3’s budget):
- When projected prompt tokens would exceed
window - reserve, summarize
older turns at clean turn boundaries (never split a tool call from its
result).
- Persist a checkpoint (summary + retained tail) on the session so the
next turn does not resend the warehouse.
- Storage may still hold the full Blob (OpenCode lesson: logical compact ≠
delete disk). Paint does not need the pre-checkpoint body.
Success: a 6-hour session on a 200k model still produces a coherent
continue; the Gateway POST stays inside the window; the agent can answer
from the checkpoint + tail + working notes (A2) + tool fold (A1).
Constraints (lock)
- Compaction text is labeled as a summary, never as live assistant
prose (honesty).
- Do not compact mid-tool-call / mid-
tool_run group.
- Function/Gateway transport ceilings still apply to the prompt we send.
- Wasm does not run the summarizer (server / host fold only).
Non-goals
Suggested next
create-plan after A3’s window source is locked (or one combined plan if
reviewer prefers). Depends on A1/A2 or the compacted summary will have
nothing useful to say about tools/findings.
Peer harness notes
Pi compaction (take the mechanics, not JSONL-on-disk):
Skip: /tree branch summaries, SQLite, part/*.json.
Orrery (2026-08-15)
Compaction is a cache-flush event. Only run it at:
Write the summary into a durable-spec slot (stable region, with #550 notes + files-touched), not as a new history head that churns every compact. Post-compact prefix bills fresh until re-warmed — do not compact mid-mechanical tool streak.
Family switch (#551) prefers the same boundary. retainedTail still starts after the checkpoint.
Parent
#548 (agent session architecture)
Problem
The only “compaction” we have is drop oldest rows and slice the
string. That is an API-payload habit. Other harnesses (Pi
CompactionEntry+retainedTail; OpenCode summary parts) compact tothe model window and keep a checkpoint so they do not re-walk the entire
log.
We need that for intelligence, independent of how Blob is paged.
Goal
A compaction mechanism keyed on model capability (A3’s budget):
window - reserve, summarizeolder turns at clean turn boundaries (never split a tool call from its
result).
next turn does not resend the warehouse.
delete disk). Paint does not need the pre-checkpoint body.
Success: a 6-hour session on a 200k model still produces a coherent
continue; the Gateway POST stays inside the window; the agent can answer
from the checkpoint + tail + working notes (A2) + tool fold (A1).
Constraints (lock)
prose (honesty).
tool_rungroup.Non-goals
%UI (harness: show live context size from model usage (not client math) #327 / feat(#539): context/usage status slot — bounded provider-usage summary (chat+agent, JSON + stream done) folded into the Wasm context slot #547)/treebranching (out of scope unless a later spike)Suggested next
create-planafter A3’s window source is locked (or one combined plan ifreviewer prefers). Depends on A1/A2 or the compacted summary will have
nothing useful to say about tools/findings.
Peer harness notes
Pi compaction (take the mechanics, not JSONL-on-disk):
contextTokens > contextWindow - reserve(inference budget: replace 400-row / 3.5M-char fold with model-window token budget #551 policy).keepRecentTokenstail; cut only on user/assistant/custom boundaries — never between
tool_useandtool_result(agent memory: structured truncated tool_result on the wire (not Tool: crumbs) #549).serializeConversation()with tool outputs capped (~2k chars) at compacttime.
“what did you already find?” works without raw dumps.
CompactionEntry+retainedTail; later builds start at thecheckpoint. OpenCode discards verbose completed tool parts from the
prompt but keeps them on disk — same as our Blob vs inference split.
Skip:
/treebranch summaries, SQLite,part/*.json.Orrery (2026-08-15)
Compaction is a cache-flush event. Only run it at:
occupancy > window − reserve).Write the summary into a durable-spec slot (stable region, with #550 notes + files-touched), not as a new history head that churns every compact. Post-compact prefix bills fresh until re-warmed — do not compact mid-mechanical tool streak.
Family switch (#551) prefers the same boundary.
retainedTailstill starts after the checkpoint.