ADR 0132 — Chat context carries across tabs: a short gist inline, the rest on demand
- Status: Accepted (2026-11-15, Josh: "sign off now, start the backend"). Backend slices boarded 2026-11-15.
- Date: 2026-11-15
- Deciders: Josh Mabry; protoAgent maintainers
- Builds on: ADR 0069 (incognito leaves no memory, D3b), ADR 0125 (the memory / knowledge / history split; the digest is an index, D2), ADR 0130 (server-held chat list), ADR 0131.
Context
Josh, 2026-11-15: "any chat tab in the agent should be able to pick up the context for the tab unless the user explicitly opts to delete the chat from memory or uses an incognito tab." Closing a tab with × deletes the chat by design. Its default dialog choice, "Save a summary", keeps its context in memory. Shift+click and bulk close are deliberate quick deletes that save nothing new.
A trace of main at e3e228830 (2026-11-15) and outside research (ChatGPT, Claude, Gemini, DeepSeek's Super-agent essay, Letta, Mem0, Zep, LangMem) found:
What a chat leaves behind:
- the transcript, kept until the chat is deleted;
- a session card: the first message plus the newest 39 messages at 500 chars each (
graph/middleware/memory.py), deleted with the chat; - compaction archives holding the full transcript, kept forever and removed only by Erase;
- a harvest summary, written on "Save a summary" or the 30-day idle sweep, which reads only the newest 16,000 chars (
graph/conversation_harvest.py_MAX_TRANSCRIPT_CHARS); - up to 12 extracted facts, taken at harvest;
- any
memory_saverows the agent chose to write.
What a new tab sees at turn 1:
- a
<prior_sessions>digest with one line per session: topic (first user message) and message count, never content, covering the newest 10 sessions in 2,000 tokens; - always-on memories;
- the top 5 relevant memories and the top 5 knowledge chunks.
Anything more requires the model to choose to call recall_session or session_search.
Gaps against the rule (verified in code):
- Incognito leak.
memory_saveandknowledge_ingest(tools/memory_tools.py) have no incognito check, and closing an incognito chat sendsforget:false. The agent can therefore write memories from an incognito chat, and they outlive it. - An open chat carries over only as a topic line. Tab B doesn't know what tab A is actually about unless the model goes looking.
- A closed, summarized chat drops out of the digest. Deleting a chat removes its session card, so its summary is only reachable via
session_search. - Automated sessions crowd the digest.
job:,palette-andsystem:activitycards take digest slots and can push real chats out. - The harvest summary loses the start of long chats. It only sees the newest 16,000 chars.
- A chat idle for 30 days loses its live context. The checkpoint sweep harvests the thread and then deletes its checkpoints (
graph/checkpoint_prune.py). Nothing rebuilds the model's context from the stored turns, so the tab still shows its history but the model starts blank. - "Continue in a new chat" makes a false promise. It tells the agent "read its full transcript with recall_session", but
recall_sessionreturns the clipped card.
Outside norm. Systems converge on a hybrid: a small distilled layer inline every turn, plus the full history pulled in by a tool on demand. DeepSeek calls this "Inline vs Spill", "wasting the context window means wasting the model's intelligence". The same pattern shows up as Claude's recent_chats plus conversation_search, ChatGPT's recent-conversation digest plus saved memories, and Letta's core blocks plus recall search. Temporary/incognito chats that neither read nor write memory are universal.
Decision
D1 — Hybrid: a short gist inline, everything else on demand
The digest stays an index (ADR 0125 D2). Each chat's entry gains a gist: one or two sentences (at most 240 chars) saying what the chat is about and where it stands. Detail remains behind recall_session / session_search. There is no new store. The gist lives on the existing session card, and the digest's existing 2,000-token budget stays.
D2 — Gists are written when a chat goes quiet, by the aux model
A chat's gist is (re)generated by the memory_gist model role (ADR 0133: a configurable model chain with fallbacks; blank inherits the aux chain, so no model is hardcoded) when the chat has gone idle (no turn for 2 minutes) and has at least 4 new messages since its last gist. This is debounced and never runs on every turn. The input is the current gist plus the messages since. Incognito chats, background: / job: / palette- / system: sessions, and goal turns never get a gist. A failed or skipped gist leaves the topic line exactly as it is today. Config: memory_session_gist: true (default), memory_gist_idle_seconds: 120, and memory_gist_model (string or list; blank inherits aux, per ADR 0133).
D3 — The digest lists chats, not machinery, and remembers recently closed chats
job:,background:,palette-andsystem:activitysessions no longer take digest slots. Every slot is a real chat.- A chat closed with "Save a summary" (or harvested by the idle sweep) stays in the digest for
memory_closed_session_days: 14(default), marked "closed". Its gist there is the first sentence of its harvest summary, and itssession_searchpointer is kept. Erase, Shift+click and bulk close leave no closed entry.
D4 — Summaries cover the whole chat
The harvest summary reads the chat's compaction archives plus its live tail. For transcripts over 16,000 chars it uses a two-step summarize: summarize each part, then combine. It no longer truncates to the newest 16,000 chars. The facts pass uses the same input.
D5 — Incognito leaves no memory, enforced on the server
memory_saveandknowledge_ingestrefuse to write in an incognito turn. They return a plain refusal the agent can relay: "This is an incognito chat, so nothing is saved to memory."- Deleting or clearing an incognito chat always forgets its session's memory rows (
forget=trueforced on the server), so anything written before this fix is cleaned up too.
D6 — An idle-pruned chat picks up where it left off
When a chat's checkpoints were pruned (aged out) but its turns still exist, its next turn starts from the chat's harvest summary plus its last 20 turns from the turn store, not from an empty context. The operator sees no change. The model regains the thread.
D7 — Honest pointers
"Continue in a new chat" stops promising a full transcript. The hidden reference becomes "recall_session(…) returns its summary and recent messages; use session_search for older detail." That wording is part of the bd-fycrd fix, which already moves the reference out of the visible composer.
Out of scope
- Fact reconciliation (Mem0-style update/delete, Zep-style invalidation). Our facts queue as "pending review"; revisit separately.
- Project- or topic-scoped memory to stop context bleeding between unrelated tabs. The rule is agent-wide carry-over; revisit only if it causes noise.
- Changing Shift+click or bulk close. They stay quick deletes by design.
Build slices (each ≤ 4 files, changelog excluded)
| Slice | What | Main files | Depends on |
|---|---|---|---|
| S1 | Incognito memory-write guard (D5, first half) | src/tools/memory_tools.py, tests/test_memory_guard.py | — |
| S2 | Incognito delete/clear always forgets (D5, second half) | src/operator_api/chat_routes.py, tests/test_forget_conversation_memory.py | — |
| S3 | Digest excludes automated sessions from slots (D3a) | src/graph/middleware/memory.py, tests/test_digest_gating.py, tests/fixtures/projection_native_golden.json (if the golden changes) | — |
| S4 | Session gist: generator plus storage on the card (D2), model via create_role_llm(config, "memory_gist") | src/graph/session_gist.py (new), src/graph/middleware/memory.py, src/graph/config.py (+ tests/test_config_roundtrip.py golden), tests/test_session_gist.py (new) | S3, ADR 0133 M2 |
| S5 | Digest renders gists (D1) | src/graph/middleware/memory.py, tests/test_digest_gating.py, golden fixture | S4 |
| S6 | Recently closed chats stay in the digest (D3b) | src/graph/conversation_harvest.py, src/graph/middleware/memory.py, src/graph/config.py, tests/test_conversation_harvest.py | S5 |
| S7 | Whole-chat harvest summary (D4) | src/graph/conversation_harvest.py, tests/test_conversation_harvest.py | S6 |
| S8 | Idle-pruned chat rehydrates from turns (D6) | the chat turn entry path (find where a turn loads its thread state, e.g. src/server/chat.py / turn stream), src/graph/checkpoint_prune.py (mark pruned threads), a new test | — |
D7 rides on bd-fycrd (already on the board).
Acceptance scenarios
- A new tab's first turn sees, for each recent open chat, a one-to-two-sentence gist of what it's about. Tested at the projection seam with a fake aux model.
- A gist is written once per quiet period, not per turn. Incognito, job and palette sessions never get one.
- A chat closed with "Save a summary" still appears in the digest, marked closed, for 14 days. One closed with Erase, Shift+click or bulk close doesn't.
- Automated sessions never take digest slots.
- The harvest summary of a 60,000-char chat reflects its opening, not just its tail.
- In an incognito chat,
memory_saverefuses, and deleting the chat removes any memory rows it holds. - A chat whose checkpoints were pruned answers its next message with knowledge of its earlier turns.
- The digest stays within its 2,000-token budget with gists on 10 chats.
Consequences
- Every chat that goes quiet costs one small call on the
memory_gistchain (cheap by default via aux), bounded by the debounce and the 4-new-message floor. - The digest gets more useful at the same token budget, because machinery lines go and real chats stay.
- Incognito becomes a real guarantee, enforced on the server.
session_search/recall_sessionare unchanged. They remain the way to get detail.