Skip to content
Lossless
Esc
↑↓navigate↵open⌘Jpreview

Pi extension · SQLite + FTS5 · MIT

Nothing is lost.The model sees less.

Aged turns become summary pointers the model can navigate. Every message behind them stays in a local store, searchable and readable in full.

pi install npm:pi-lossless
default swap point
70%
default recent budget
20k
recall tools
3
tool call to read an original
1

THE PROJECTION

What the model sees, and what it can still read.

Two layers, one session. The window is what the model pays for on every turn; the store is what it can still reach.

context · what the model receives

20k tokens recent · 3 pointers

summary 07 · 8 children

summary 08 · 4 children

summary 09 · 2 children

swap point · 70%

user
assistant
user
assistant

every line below the swap point is byte for byte what was typed

on disk · the store

every message · FTS5 indexed

oldest

now

HOW IT WORKS

Four moves, one store.

The first three steps run without the model asking. The fourth is a tool call the model makes.

  1. 01

    Log

    Every turn is written to SQLite behind a full-text index. Below the swap point the model still sees the conversation itself.

  2. 02

    Swap

    Past the swap point the aged head becomes one summary pointer. Nothing else in the context moves.

  3. 03

    Condense

    Deeper passes fold the frontier into a DAG, up to 8 children per node. Every node expands back to the messages under it.

  4. 04

    Recall

    The model greps, describes, and reads the originals by address, and only the read leaves the main loop.

depth 2 · frontier

#15 · 1,930 tok · e12..e238

depth 1

#11 · 1,412 tok · e12..e103#12 · 1,412 tok · e104..e238

depth 0 · leaves

#7 · e12..e40#8 · e41..e103#9 · e104..e170#10 · e171..e238
The shape behind a window pointer, drawn with four leaves. Real sessions carry many more. Schematic, not to scale.

ZONES

A soft point, not the hard limit.

Model quality falls off before the context window is full. LCM swaps on a token budget you set, and stays quiet below it.

0 to 70%

Quiet

The projection is the conversation itself, so a provider's cached prefix stays valid turn after turn.

70 to 85%

Swapped

Swaps append a pointer and leave the rest of the context byte for byte.

85% to the window

Recut

One re-cut replaces the previous shape, and the frontier folds a depth at a time.

KEYDEFAULT
swapAtRatio0.7of the model's window
recutAtRatio0.85the re-cut, strictly above swap
keepRecentTokens20,000tokens left verbatim at the tail
zones[model]per modeltoken overrides win

WHEN IT RUNS

REGIMEWHAT LANDS, AND WHEN
AsyncSwaps wait for a commit boundary and land between turns, never mid-turn.
BlockingAt Pi's compaction limit, LCM replaces default compaction with escalated summaries, and falls back on failure.

RECALL

Reading an original costs one tool call.

Searching and inspecting run in the main loop. The read goes to a bounded reader, so a 200,000-character message can be read without the text entering the conversation.

lcm_grep

Search the archive

Keyword or pattern search across every stored message and summary. The model asks a question and gets the message addresses that match.

lcm_grep({ query: "swap point" })

lcm_describe

Inspect a summary

Kind, depth, covered span, and the cost of expanding it. The model gets this without pulling the original text into the loop.

lcm_describe({ id: 12 })

lcm_expand_query

Read the originals

Expands the stored messages and answers from them, so the history is available without being replayed in full.

lcm_expand_query({ prompt, id })

INSTALL

One extension, or one engine.

The extension is what a Pi user installs. The engine is what another harness drives, behind two ports and no agent SDK.

pi-lossless

The Pi extension

The recall tools, the cockpit and the commands, with the engine inlined so the installed package stays a single artifact.

  • lcm_grep · lcm_describe · lcm_expand_query
  • Cockpit and slash commands
  • Escalated compaction at the limit
pi install npm:pi-lossless

lossless-core

The engine

Ingest, compaction and retrieval behind a two-port host contract. A harness implements ModelHost and Reader, and names no agent SDK.

  • Verbatim ingest with FTS5
  • Summary pointers and a DAG frontier
  • Escalated summaries that converge
npm install lossless-core

Install it, then leave it alone.

Every session after that one is logged, searchable, and rebuildable from the session file.

pi install npm:pi-lossless