Skip to content
This repository was archived by the owner on Sep 8, 2026. It is now read-only.
This repository was archived by the owner on Sep 8, 2026. It is now read-only.

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

Closed

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

  1. btipling commented on Aug 19, 2026

    @btipling
    OwnerAuthor

    2026-08-19 source-level peer research

    Compaction is how a long session stays one mind after the window fills. Locks for the create-plan:

    Persist the replacement, not just a summary string

    Peer What resume sees
    Codex Compacted.replacement_history on the rollout — resume == live post-compact vector
    OpenCode typed session_message type: "compaction" { summary, recent }; history query cuts off at that seq; new Context Epoch
    DeepSeek surfaceOp: replace on the model-visible surface; log intact (FTS can still find shadowed reads)
    OMP CompactionEntry + tail; default snapcompact PNG archive (vision). Skip the PNGs.

    Steal Codex/OpenCode: the checkpoint we persist is the next Function’s model-facing history, not a prose souvenir we re-fold from 8 MiB of paint. Device-switch resume must see the same compacted view.

    Do not delete the Blob when we compact the prompt (OpenCode: logical compact ≠ delete disk). We have no DeepSeek session-query FTS over shadowed ranges — so the summary must carry findings: files-touched, decisions (#550 notes kept verbatim), not “we looked at some files.”

    Tool outputs after compact

    Codex is harsher than DeepSeek: tool results are dropped from the live vector. OpenCode hides old rows from SessionHistory.load. After compact, #693 becomes urgent: even the stale snapshot is gone; the model re-reads from the files-touched list.

    Never cut between tool_use and tool_result (already in the body). Checkpoint is labeled summary, never live assistant prose.

    When

    Keep the Orrery lock: phase boundary (#536 tags) or hard ceiling (occupancy > window − reserve). Mid-turn compact (OMP default true) is a Function-timeout hazard on Vercel — prefer turn-boundary unless the create-plan proves a mid-loop compact fits maxDuration.

    Skip: snapcompact pixel-font frames, /tree branch summaries, SQLite SoT, rewriting history in place as Codex’s only store (we already persist Blob).

  2. added 2 commits that reference this issue on Sep 7, 2026
  3. btipling commented on Sep 7, 2026

    @btipling
    OwnerAuthor

    Done — model-capability compaction is on main via parent #947 (phases 1–5) and merge #957 (b31ca512e7ddee162fa8313cc52f549822e2d23a).

    Checkpoint + retained tail keyed on the selected model's window − reserve; honesty-labeled summary; logical compact (Blob history retained); Wasm does not run the summarizer.

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