Keep chat history fully ephemeral in demo mode#4
Merged
Conversation
Demo mode was only ephemeral at the session-store layer (get_sqlite_session_store returns an in-memory DB). But the turn runtime still mirrored every turn's full transcript to data/user/workspace/<capability>/<turn_id>/events.jsonl on disk on every turn, and the memory subsystem still wrote L1 traces and L3 preferences to disk when RAG search or the write_memory tool ran. So conversation history kept landing on disk even with DEMO_MODE=1. Add a shared is_demo_mode() guard and skip the three conversation-derived disk-write paths when demo mode is on: - turn_runtime._mirror_event_to_workspace (events.jsonl transcript mirror) - memory.trace.append (L1 trace of queries / stated preferences) - memory.store.write_preference (L3 preferences.md) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
History was still being persisted to disk even with
DEMO_MODE=1.Demo mode was only ephemeral at the session-store layer —
get_sqlite_session_store()swaps in an in-memory SQLite DB sodata/user/chat_history.dbis never written. But three other per-turn/tool disk-write paths ignored demo mode entirely, so conversation-derived content kept landing on disk:turn_runtime._mirror_event_to_workspacedata/user/workspace/<capability>/<turn_id>/events.jsonlmemory.trace.appenddata/memory/trace/<surface>/<date>.jsonlwrite_memorytoolmemory.store.write_preferencedata/memory/L3/preferences.mdwrite_memorytoolFix
is_demo_mode()guard indeeptutor/services/demo(reuses the process-wide limiter, so the answer is consistent everywhere and honours test overrides).write_preferencereturnsApplyReport(accepted=False, reason="demo mode: memory not persisted")so the caller sees an honest no-op.This makes the demo's "chat history stays ephemeral / never written to disk" contract actually hold across the whole surface, not just the SQLite store.
Testing
tests/services/demo/test_demo_ephemeral_persistence.py— each culprit path is asserted to be a no-op whenDEMO_MODE=1and to still write when it's off (regression guard).🤖 Generated with Claude Code