Desktop: improve local SQLite tool discoverability for chat
Problem
The desktop chat LLM tools (execute_sql, semantic_search, get_daily_recap) have extremely limited visibility into the local omi.db database. Users report missing data in query results.
Current state:
- LLM only knows about 3 of 20+ tables (
screenshots,transcription_sessions,action_items) - FTS5/BM25 tables exist and work internally, but are deliberately hidden from the LLM (
if name.contains("_fts") { continue }) semantic_searchonly covers screenshots — task/memory embeddings exist but aren't exposed- Column visibility is ~25% per table (e.g.,
action_itemshas 35+ columns but LLM sees 4) - No table relationships documented
Proposed Changes
Scope 1: Schema & Prompt Discoverability (P0)
B. Add missing tables to schema — Expose these tables in formatSchema() and tool descriptions:
memories(user facts, preferences, habits)staged_tasks(overflow task buffer — top 5 go toaction_items, rest here)goals(user goals and objectives)focus_sessions(focus/distraction tracking)observations(screen context summaries)indexed_files(local file inventory)transcription_segments(actual transcript text per speech segment)live_notes(AI-generated notes during recording)local_kg_nodes/local_kg_edges(knowledge graph)task_chat_messages(task conversation history)ai_user_profiles(daily AI profile snapshots)
F. Document key columns per table — Instead of just table names, list 5-8 key queryable columns per table. Avoid dumping blob/sync columns to keep token cost low.
D. Document table relationships — Add relationship hints:
action_items.screenshotId→screenshots.idaction_items.conversationId→transcription_sessions.idtranscription_segments.sessionId→transcription_sessions.idobservations.screenshotId→screenshots.idfocus_sessions.screenshotId→screenshots.idmemories.screenshotId→screenshots.id
A. Expose FTS5 tables and document MATCH syntax — Remove the _fts filter in formatSchema(). Allowlist only top-level FTS virtual tables (not shadow tables). Document 2-3 safe query patterns:
-- Keyword search on screenshots
SELECT s.* FROM screenshots s
JOIN screenshots_fts ON screenshots_fts.rowid = s.id
WHERE screenshots_fts MATCH 'keyword'
-- BM25-ranked task search
SELECT a.*, bm25(action_items_fts) as rank FROM action_items a
JOIN action_items_fts ON action_items_fts.rowid = a.id
WHERE action_items_fts MATCH 'keyword'
ORDER BY rank
Scope 2: Retrieval Capabilities (P1)
C. Expose task/memory vector search — Add a dedicated search_tasks tool that uses the existing EmbeddingService in-memory vector index (action_items + staged_tasks). A dedicated tool is more reliable than asking the LLM to hand-write MATCH queries. Keep FTS-via-execute_sql as an escape hatch.
E. Enrich get_daily_recap — Add queries for:
focus_sessions(focus/distraction events)memoriescreated that dayobservationscontext summaries
Key Files
| File | What to change |
|---|---|
Desktop/Sources/Chat/ChatPrompts.swift |
formatSchema() — remove _fts filter, add missing tables, add column docs |
Desktop/Sources/Providers/ChatToolExecutor.swift |
Add search_tasks tool, update get_daily_recap queries |
acp-bridge/src/omi-tools-stdio.ts |
Add new tool definitions, update execute_sql description with full schema |
agent-cloud/agent.mjs |
Mirror tool description updates |
Priority
Per CODEx consultation:
- P0: B (missing tables) → F (key columns) → D (relationships) → A (FTS exposure)
- P1: E (enrich daily recap) → C (vector search tool)
Rationale: B/F/D fix discoverability fast with minimal risk. A helps once tables are visible. E is useful but narrow. C requires the most work (local memories table doesn't have an embedding column yet).
Token Cost Mitigation
Keep schema compact: table name + 5-8 key columns + 1-line relationship note. Avoid raw DDL, blob columns, and FTS shadow tables. Consider on-demand sqlite_master lookup for deeper inspection.
References
- PR #6465 (enriched tool descriptions — first pass)
- Issue #6444 (adopt backend agentic tool patterns)
I have noticed in the past when I have asked omi something about a conversation in the past it would say it couldn't find it. Then I would go looking directly at the day and see it there and ask omi about it. And it was like oh yeah sorry. It was funny, but I wonder if that is somehow related.
If data ages out, of sorts, not being cached anymore, and there was more context to search more exposed data that that stayed around could better prompt retrieval of the data no longer cached.
Hopefully I'm not babbling.