Why AI Coding Sessions Need a Local-First Memory Layer
Modern AI engineering workflows span multiple tools—IDE assistants, CLI coding agents, and cloud-hosted LLM workbenches. Over the past year, my daily architecture and mobile engineering work accumulated more than 500 multi-turn AI sessions across different environments. Every time a new session started, valuable architectural reasoning, debugging traces, and design trade-offs vanished behind fragmented local logs.
Uploading raw personal and engineering chat logs wholesale into a third-party cloud vector store creates two immediate problems: latency/cost bloat and privacy boundaries. A cleaner pattern is a hybrid local-first architecture: keep full-text indexing and privacy-boundary filtering local on disk, and send only compact, redacted context snippets to cloud foundation models on Amazon Bedrock when deep synthesis is required.
Architecture Overview
- Local Ingestion & Normalization (Rust)
- Parses heterogeneous JSONL / SQLite session transcripts into a normalized relational schema (
conversations,messages,artifacts). - Built in Rust (
chat-memory-mcp, open-sourced athttps://github.com/leotyndale/chat-memory-mcpand installable viabrew install leotyndale/tap/chat-memory-mcp) for millisecond startup time and zero runtime dependencies.
- Parses heterogeneous JSONL / SQLite session transcripts into a normalized relational schema (
- Sub-10ms Hybrid Retrieval (SQLite FTS5)
- Uses SQLite FTS5 with BM25 ranking so developers can query tens of thousands of historical engineering turns locally with zero token spend and zero network round trips.
- IDE & Agent Integration (Model Context Protocol + JetBrains Plugin)
- Exposes structured tools (
search_sessions,get_session_summary,retrieve_decision_trace) over stdio MCP so any MCP-compatible coding agent or IDE plugin (chat-memory-jetbrains, JetBrains Marketplace ID36557) can query historical decisions on demand.
- Exposes structured tools (
- Cloud Synthesis Layer (Amazon Bedrock + Guardrails)
- Only after local FTS5 narrows 15,000+ steps down to the top 5–8 relevant, PII-scrubbed excerpts does the workflow invoke Amazon Bedrock (e.g., Claude / Nova models via AWS SDK for Rust
aws-sdk-bedrockruntime) with Amazon Bedrock Guardrails enabled to enforce sensitive-information redaction and structured JSON output.
- Only after local FTS5 narrows 15,000+ steps down to the top 5–8 relevant, PII-scrubbed excerpts does the workflow invoke Amazon Bedrock (e.g., Claude / Nova models via AWS SDK for Rust
Key Engineering Trade-Offs
- Zero-Token Pre-Filtering: Filtering 99% of irrelevant history locally with SQLite FTS5 reduces downstream cloud prompt tokens by an order of magnitude and keeps prompt-cache hit rates high.
- Deterministic Privacy Gates: A pre-flight regex and allowlist filter strips credentials, local filesystem usernames, and internal identifiers before any payload leaves the developer workstation for Bedrock.
- Cross-IDE Portability: Decoupling the core engine as a standalone Rust MCP binary lets the same local index serve JetBrains IDEs, VS Code, and CLI agents simultaneously.
Try It Yourself
brew install leotyndale/tap/chat-memory-mcp Source code and architecture docs are open-sourced at https://github.com/leotyndale/chat-memory-mcp. Feedback, benchmarks, and AWS Bedrock integration PRs are warmly welcome!
