Skip to content

compaction: model-capability context compaction (not API payload slices) #552

Description

@btipling

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions