← All Diagrams
Database Schema (web.db)
SQLite database with WAL mode and foreign keys enabled. 14 tables covering web conversations,
group chats, agent definitions, MCP servers, scheduled tasks, reactions, and read receipts.
Defined in web/database.py with inline migrations for schema evolution.
conversations
PK: id TEXT
title, agent_type, project_dir, model, backend_session_id
source (web|telegram|scheduled), telegram_window_id
total_input_tokens, total_output_tokens, total_cost_usd
total_cache_read/write, total_tool_calls, tokens_remaining_pct, is_active
messages
PK: id TEXT
FK: conversation_id → conversations (CASCADE)
role, content, turn_sequence, event_sequence, status, agent_type
tool_calls
PK: id TEXT
FK: conversation_id → conversations (CASCADE)
tool_name, input_params, output_result, status, agent_type, duration_ms
turn_usage
PK: id INTEGER AUTOINCREMENT
FK: conversation_id → conversations (CASCADE)
turn_seq, in/out/cache tokens, cost, duration, stop_reason
GROUP CHAT
group_messages
PK: id INTEGER | UNIQUE(conv_id, sequence)
FK: conversation_id → conversations (CASCADE)
sequence, sender, content, thread_id, mentioned_agent
group_agent_sessions
PK: (conversation_id, agent_type)
FK: conversation_id → conversations (CASCADE)
backend_session_id, model, tokens, cost, tool_calls
group_conversation_agents
PK: (conversation_id, agent_key)
FK: conversation_id → conversations (CASCADE)
FK: agent_def_id → agent_definitions
message_reactions
UNIQUE(conv_id, seq, reactor, emoji)
FK: conversation_id → conversations
group_read_receipts
PK: (conv_id, seq, agent_key)
FK: conversation_id, read_at
group_chat_prompts
PK: id TEXT (default: 'default')
name, content, poll_timeout, max_turns
agent_definitions
PK: id TEXT
name (UNIQUE), display_name
backend, model, role, goal, backstory
MCP SERVERS
mcp_servers
PK: name TEXT
transport, url, command, args, env, headers, enabled
conversation_mcp_servers
PK: (conversation_id, server_name)
FK: conversation_id, FK: server_name (CASCADE)
SCHEDULED TASKS
scheduled_tasks
PK: id TEXT
name, cron_expr, agent_type, prompt, timeout, overlap
scheduled_task_executions
PK: id TEXT
FK: task_id, FK: conv_id (SET NULL), status
scheduled_task_mcp_servers (FK: task_id, server_name)
SQLite WAL mode · PRAGMA foreign_keys=ON · PRAGMA synchronous=NORMAL · web/database.py