Skip to content

Conversational Memory

Every conversation is stored, searchable, and summarized — so the agent picks up exactly where it left off.

Messages are dual-written to two stores:

  • JSONL (source of truth) — Append-only log of all messages
  • SQLite (query engine) — FTS5 full-text search index, derived from JSONL

The SQLite index can be deleted and rebuilt anytime from the JSONL source.

LLM-generated conversation summaries update incrementally as conversations grow. These summaries are injected as highest-priority context on session start and after compaction.

This means the agent never starts cold — it always has the context of what was discussed before.

Search across all agent knowledge:

Terminal window
# CLI
instar memory search "deployment strategy"
# API
curl "localhost:4040/memory/search?q=deployment+strategy"

Search covers AGENT.md, USER.md, MEMORY.md, relationships, and conversation history.

In addition to FTS5 keyword search, instar supports semantic search via vector embeddings using the sqlite-vec extension. Semantic search finds conceptually-related content even when the exact words don’t match — searching for “deployment strategy” turns up entries about “rollout plans” and “shipping cadence” too.

Terminal window
# Semantic search via CLI
instar semantic search "rollout strategy"
# Specific semantic API operations
curl "localhost:4040/semantic/recall?q=...&limit=10"
curl -X POST localhost:4040/semantic/remember -d '{"text": "..."}'
curl -X POST localhost:4040/semantic/connect -d '{"from": "id1", "to": "id2"}'

The embedding provider is pluggable. Built-in providers cover OpenAI, Anthropic, and local model backends. Configure via the embedding block in .instar/config.json.

If the sqlite-vec extension isn’t available on your host (it ships as a native binary that not every platform has prebuilds for), semantic search falls back to FTS5 transparently. You won’t see vector-style results, but you also won’t see an error — keyword search keeps working. Verify which mode is active:

Terminal window
curl localhost:4040/memory/status

Components: WorkingMemoryAssembler, MemoryIndex, Chunker, EvidenceRenderer.

The agent’s session context isn’t loaded wholesale from disk. The working memory assembler picks what’s relevant for the current turn — recent messages, salient memories, evidence rows from the decision journal, identity files — and assembles them into the prompt context. The chunker handles long source documents by splitting them into searchable units while preserving boundaries. The evidence renderer formats memory entries with provenance citations so the agent can ground claims in specific past observations rather than fuzzy recall.

This is the subsystem responsible for “the agent remembers exactly what you discussed three weeks ago when it’s relevant.” It runs invisibly on every session start and after every compaction.

Terminal window
# Get summary + recent messages for a topic
curl localhost:4040/topic/context/TOPIC_ID
# List all topic summaries
curl localhost:4040/topic/summary
# Trigger summary regeneration
curl -X POST localhost:4040/topic/summarize

With the context layers on, each topic keeps a layered memory. Read-only views report sizes, statuses and verdicts, never the words: GET /topic/:id/user-corpus (the operator’s own messages), GET /topic/:id/anchor (the topic’s Anchor and decisions), GET /topic/:id/chunks and GET /topic/:id/chunks/:k (chunk summaries), and GET /topic/:id/standing-packet (what a session is re-seeded with after a compaction). GET /context-budget/layers and GET /context-budget/metrics show the layers’ status and cost, and GET /context-budget/sentinel shows the compaction canary and the adapter verification suite’s recorded results.

Codex has no hook that runs right after it compacts a conversation, so a Codex topic session gets its context back on the next prompt instead. The per-prompt hook asks POST /context-budget/codex-seed. If this is the first prompt since a compaction, the answer is the topic’s verified standing packet, and it is printed in place of the usual briefing. The hook then confirms with POST /context-budget/codex-seed/ack, which records that compaction as recovered. Each compaction is seeded once. A packet that fails verification is never sent; that prompt gets the usual briefing. GET /context-budget/codex-seed shows the counts. All three return 503 while the context layers are off.

Terminal window
instar memory reindex # Rebuild the search index
instar memory status # Index stats

Long conversations are compressed by Claude Code when they near the context window. Instar’s context-budget work keeps what matters across that compression: a short, current summary of each conversation, a durable record of its decisions, and an archive of the transcript that was folded away.

Terminal window
# The compaction-recovery health check, per machine and engine: whether every
# compaction got its recovery block (healthy, accruing, diverged, uninitialized),
# including recoveries that were cut to a preview by the hook-output limit.
curl -H "Authorization: Bearer $AUTH" localhost:4040/context-budget/sentinel
# The per-topic summary store and transcript archive on this machine:
# roots and permissions, topics, bytes, and replication outcomes.
# Returns 503 while contextBudget.enabled is off (it is on for development agents only).
curl -H "Authorization: Bearer $AUTH" localhost:4040/context-budget/layers
# The chapter summaries ("chunks") of a conversation's older, compressed detail,
# newest first and paginated, then one chunk in full by its number.
# Both return 503 while the layers are off.
curl -H "Authorization: Bearer $AUTH" "localhost:4040/topic/141133/chunks?limit=10"
curl -H "Authorization: Bearer $AUTH" localhost:4040/topic/141133/chunks/3
RouteWhat it returns
GET /topic/:id/chunksOne page of a topic’s chunk summaries, newest first, with their message ranges and status (pending, built, failed).
GET /topic/:id/chunks/:kOne chunk: its summary, the message range it covers, what the sampler left out, and its author and as-of time.

Everything written to the summary store is scrubbed of secrets first, and the operator’s own words are never copied into it: the store only keeps a pointer to the original message and a fingerprint of it.

The context budget keeps a long conversation’s context in layers and restores it after a compaction. Every route needs the bearer token.

  • GET /context-budget/sentinel — the ContextBudgetSentinel’s status: the compaction canary per machine and engine, the heal ladder’s recent decisions (cause, action, outcome) and its breaker, and the synthetic press’s last outcome. 503 while contextBudget.sentinel.enabled is off.
  • POST /hooks/post-compact — where the PostCompact hook sends Claude’s compact_summary; stored scrubbed under the session’s topic (a throwaway synthetic-press session files under its own press key).
  • GET /context-budget/layers — the layer store’s status, including the standing packet’s counters.
  • GET /context-budget/metrics — the context-budget card’s numbers.
  • GET /topic/:id/anchor — a topic’s Anchor and its decisions and evolutions ledger.
  • GET /topic/:id/chunks — a topic’s chunk summaries; GET /topic/:id/chunks/:k reads one.
  • GET /topic/:id/user-corpus — the size of a topic’s operator corpus.
  • GET /topic/:id/standing-packet — a topic’s standing packet: sizes, sections and the verifier’s verdict, never the words.
Terminal window
curl -H "Authorization: Bearer $AUTH" localhost:4040/context-budget/sentinel
curl -H "Authorization: Bearer $AUTH" localhost:4040/context-budget/layers
curl -H "Authorization: Bearer $AUTH" localhost:4040/context-budget/metrics
curl -H "Authorization: Bearer $AUTH" localhost:4040/topic/TOPIC_ID/anchor
curl -H "Authorization: Bearer $AUTH" localhost:4040/topic/TOPIC_ID/chunks
curl -H "Authorization: Bearer $AUTH" localhost:4040/topic/TOPIC_ID/user-corpus
curl -H "Authorization: Bearer $AUTH" localhost:4040/topic/TOPIC_ID/standing-packet

The canary’s heal ladder acts by cause, through bounded brakes: a missing hook re-runs the hook migration; a compaction whose briefing never reached the session gets its standing packet re-delivered once at an idle prompt; anything else is recorded only. Its positive control is a compaction the sentinel presses on a throwaway session (name starting cb-press-, bound to no channel), never on a live conversation.