Conversation Intelligence

Last updated: April 10, 2026

Conversation Intelligence System

File: assistant/conversation_intelligence.go (~1684 lines)

The Conversation Intelligence system is a 3-phase memory pipeline that transforms raw chat sessions into structured, retrievable knowledge. It powers long-term memory, persona continuity, and autonomous playbook discovery.

Architecture Overview

Chat Session Ends
    ↓
Phase 1: generateConversationSummary()
    → Structured JSONL output (WIS/WIH/WID model)
    → Significance scoring (1-5)
    ↓
Phase 2: RunMemoryDistillation()
    → Processes unprocessed JSONL conversations
    → Routes insights to 3 memory tiers
    → User-isolated processing
    ↓
Phase 3: triggerPlaybookDiscovery()
    → Identifies repeatable workflow patterns
    → Generates playbook candidates
    → Saves to assistant/memory/playbooks/candidates/

Phase 1: End-of-Session Summaries

When a chat session completes, generateConversationSummary() runs asynchronously via goroutine.

Summary Model: openrouter/qwen/qwen3.5-flash-02-23

Output Structure (ConversationSummary):

Field Description
Intent Primary intent of the conversation
TechnicalDepth Depth level (casual, moderate, expert)
UserMood Detected emotional state
Significance 1-5 scale (1=Transient, 5=Foundational)
RelationshipNotes Interpersonal dynamics observed
ActiveGoals Extracted goals (gated to nikki, lia, marvin only)
WIH/WIS/WID What I Heard / What I Said / What I Did model
ToolsUsed Array of {Name, Purpose} tool usage
Outcome Resolution status (resolved, partial, unresolved)
FactsLearned New factual knowledge
PreferencesNoted User preference observations
ErrorsEncountered Technical failures
FollowUp Suggested next actions
Distilled Whether this has been through distillation

Retry Logic: 3 retries with exponential backoff (5s, 10s, 20s) on LLM failures.

Storage: JSONL per agent at assistant/memory/{agent}_conversations.jsonl

Excluded Agents (memorySkipAgents): mrtool, analyst, sysadmin, ceo, director, team_leader, employee, elon, projectmanager, queen, bee, worker, scout, soldier, debugger, janitor, memorymaster, memorymanager, accountant, developer, marketing, sales_rep

Phase 2: Memory Distillation

RunMemoryDistillation(targetUser) processes unprocessed conversation summaries and routes insights to three memory tiers:

Memory Tiers:

Tier File Max Size Content
Shared assistant/memory/shared_long_term.md 4,000 chars Cross-agent knowledge
Agent assistant/memory/{agent}_long_term.md 8,000 chars Agent-specific expertise
User assistant/memory/{user}/{agent}_memory.md 4,000 chars Per-user personalization

RBAC Gating: Guest users only see their own user-level memory. Shared and agent memories are restricted to Friend+ roles.

Significance Priority: When truncation is needed, foundational entries (significance 4-5) are preserved first, then utility (3), then recent (1-2).

Concurrency: Each memory file path gets its own mutex via getMemoryFileMutex() to prevent write races.

Distillation Limits: Max 50 conversations per pass (maxJSONLEntriesPerDistillation).

Phase 3: Playbook Discovery

triggerPlaybookDiscovery() analyzes conversation patterns to identify repeatable workflows:

Requirements for a candidate:

  • 4+ distinct tool uses in the pattern
  • 3+ occurrences of the pattern
  • high or medium confidence only

Output: Candidates saved to assistant/memory/playbooks/candidates/ and notified to Dan via WhatsApp.

Memory Maintenance

ProcessMemoryMaintenance() orchestrates the full cycle:

  1. RunMemoryDistillation() — extract insights from conversations
  2. RunMemoryReflection() — "The Big Tidy": retroactively assigns significance, merges redundant facts, prunes low-signal entries, converts to WIS/WIH/WID format

Config:

Constant Value Purpose
ConversationSummaryModel openrouter/qwen/qwen3.5-flash-02-23 LLM for summarization
playbookLookbackDays 14 How far back playbook discovery looks
maxJSONLEntriesPerDistillation 50 Max conversations per distillation pass
maxSharedMemoryChars 4,000 Shared memory budget
maxAgentMemoryChars 8,000 Agent memory budget
maxUserMemoryChars 4,000 User memory budget

Key Functions

Function Purpose
generateConversationSummary() Phase 1: LLM-powered structured summary of chat session
RunMemoryDistillation() Phase 2: Process conversations, route to memory tiers
RunMemoryReflection() Phase 2+: Retroactive significance, dedup, WIS/WIH/WID conversion
BuildMemoryContext() Assemble 3-tier memory context for agent prompts
triggerPlaybookDiscovery() Phase 3: Find repeatable workflow patterns
shouldSkipMemory() Check if agent is excluded from memory saving
loadMemoryFile() Load + truncate memory with significance prioritization
lockedAppendToFile() Thread-safe file append with per-path mutex

See also: Playbook System, Tools, Skills & Memory