Skip to content

Keep chat history fully ephemeral in demo mode#4

Merged
Ho1yShif merged 1 commit into
mainfrom
fix/demo-mode-ephemeral-history
Jul 14, 2026
Merged

Keep chat history fully ephemeral in demo mode#4
Ho1yShif merged 1 commit into
mainfrom
fix/demo-mode-ephemeral-history

Conversation

@Ho1yShif

Copy link
Copy Markdown
Collaborator

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 so data/user/chat_history.db is never written. But three other per-turn/tool disk-write paths ignored demo mode entirely, so conversation-derived content kept landing on disk:

Path What it wrote When
turn_runtime._mirror_event_to_workspace Full turn transcript → data/user/workspace/<capability>/<turn_id>/events.jsonl Every turn (always-on culprit)
memory.trace.append L1 trace of user queries / stated preferences → data/memory/trace/<surface>/<date>.jsonl On RAG search or write_memory tool
memory.store.write_preference L3 data/memory/L3/preferences.md On write_memory tool

Fix

  • Add a shared is_demo_mode() guard in deeptutor/services/demo (reuses the process-wide limiter, so the answer is consistent everywhere and honours test overrides).
  • Skip each of the three disk writes above when demo mode is on. write_preference returns ApplyReport(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

  • New tests/services/demo/test_demo_ephemeral_persistence.py — each culprit path is asserted to be a no-op when DEMO_MODE=1 and to still write when it's off (regression guard).
  • Full demo, memory, session, and turn-event suites pass (315+ tests). Pre-commit (ruff, ruff format, bandit, mypy) all green.

🤖 Generated with Claude Code

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>
@Ho1yShif Ho1yShif merged commit 0f2f835 into main Jul 14, 2026
11 checks passed
@Ho1yShif Ho1yShif deleted the fix/demo-mode-ephemeral-history branch July 14, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant