How Newt manages context
A model's window is small and every turn re-sends it. When the window nears its budget, Newt does not throw the middle away. It keeps the task, keeps the recent work, saves the rest verbatim, and leaves the model a way to ask for it back. Step through one compaction below.
Context window (what the model sees)
Spill store (content-addressed, off-window)
Token counts and the handle are illustrative. The stages follow newt-core/src/agentic/compress.rs. Keys: left/right arrows step, space plays or pauses.
Going further
How agent-frame relates: this page is the default compaction path, which does not use it. The opt-in smart harness does, to record the session and validate which context to keep.
Paged context is the design that would extend this: bounded residency with unbounded reach, served from a derivation graph. It is not built yet, and the page says which parts are.
What each stage maps to
| Stage | What it does | Where |
|---|---|---|
| Structural prune | Zero-LLM-cost passes shrink stale tool output first. Most triggers end here. | compress.rs |
| Boundary | Head is every leading system message plus the active-prompt card, so the task can never be summarized away. The tail is protected by a token budget, with the latest user message anchored in it. The cut never splits a tool call from its result. | compress.rs |
| Spill | The verbatim middle is redacted and stored under a content-addressed handle (a BLAKE3 CID). Same bytes, same handle. | spill identity decision |
| Summarize | A summarizer writes a reference-only card, fenced by start and end markers so weak local models do not read it as a fresh request. No summarizer, or a failed one, falls back to a plain “N messages were removed” marker and the turn goes on. | compress.rs |
| Page fault | The model calls memory_fetch with the handle and gets the verbatim span back, only when it needs the detail. |
newt-core/src/agentic/memory_fetch.rs |
| Anti-thrash | Two compactions in a row that each reclaim under 10% turn auto-compaction off for the session and tell the operator once. The budget guard stays hard: an over-budget send is refused, never silently truncated. | CompressState in compress.rs |
Built, and not yet built
The design behind this is progressive disclosure: the window is a budgeted resource and the model pulls what it needs. The model is never told it holds everything. It is told what it holds and that the rest is reachable, because a confident summary suppresses re-reading while a labelled absence prompts it (measured here).
The wider idea, paged context over a derivation graph, is recorded intent and has no implementation yet. The animation above does not depict it; the linked page animates the design and labels it as such.
Try it
git clone https://github.com/Gilamonster-Foundation/newt-agent
cd newt-agent
just install
newt
The first run opens a setup wizard. newt --help is the authority on what the binary does.
Source: newt-agent site/context.html at 67b24697. newt-agent is Apache-2.0: Gilamonster Foundation / newt-agent.
Revisions
- · claude-sonnet-5-5 · Moved from newt-agent site/context.html at 67b24697; prose converted to Markdown, animation text moved to copy.