session-search
Session Search & Retrieval
Multiple ways to search and retrieve past session data, from high-level plugin tools to raw database queries. Pick the right approach based on what you need.
Decision Tree
Need conversation content from a specific session?
→ session_get (compressed, structured)
Need to browse/filter sessions by title?
→ session_list (quick metadata scan)
Need to search INSIDE message content across sessions?
→ grep/ripgrep on legacy JSON, or SQL LIKE on messages table
Need to find sessions by semantic meaning (not exact keyword)?
→ lss over the storage directory
Need cost/token stats or complex joins?
→ Direct SQLite queries
Need to check what's running right now?
→ REST API: GET /session/status
1. Plugin Tools (Recommended First Choice)
Two tools provided by kortix-sys-oc-plugin (the unified Kortix system plugin).
session_list
Browse sessions with metadata. No content, just IDs/titles/timestamps/stats.
session_list() # 20 most recent
session_list({ search: "auth" }) # filter by title
session_list({ limit: 50 }) # more results
Returns per session: ID (ses_*), title, created/updated timestamps, file change stats (files/additions/deletions), parent ID if subtask, plus storage paths for raw access.
session_get
Retrieve a session's full conversation, compressed via TTC bear-1.2.
session_get({ session_id: "ses_abc123" }) # default aggressiveness 0.3
session_get({ session_id: "ses_abc123", aggressiveness: 0.1 }) # light, most detail kept
session_get({ session_id: "ses_abc123", aggressiveness: 0.7 }) # heavy, just the essence
| Aggressiveness | Token reduction | When to use |
|---|---|---|
| 0.1 | ~10% | Recent/important sessions, need full detail |
| 0.3 | ~16% | Default — balanced |
| 0.5 | ~22% | Older sessions, broad strokes |
| 0.7+ | ~31%+ | Scanning many sessions, just need the gist |
Returns: metadata header (never compressed) + compressed conversation + tool call summaries + compression stats.
Requires TTC_API_KEY env var. If missing, returns uncompressed.
2. Raw SQLite Queries
The authoritative data store. Best for complex queries, aggregations, cost analysis.
Database: /workspace/.local/share/opencode/opencode.db
Common Queries
# List recent sessions
sqlite3 /workspace/.local/share/opencode/opencode.db \
"SELECT id, title, created_at FROM session ORDER BY created_at DESC LIMIT 10;"
# Find sessions by title keyword
sqlite3 /workspace/.local/share/opencode/opencode.db \
"SELECT id, title FROM session WHERE title LIKE '%auth%';"
# Session cost summary (most expensive first)
sqlite3 /workspace/.local/share/opencode/opencode.db \
"SELECT m.session_id, s.title, SUM(m.cost) as total_cost
FROM message m JOIN session s ON m.session_id = s.id
GROUP BY m.session_id ORDER BY total_cost DESC LIMIT 10;"
# Find sessions with the most tool calls
sqlite3 /workspace/.local/share/opencode/opencode.db \
"SELECT m.session_id, s.title, COUNT(*) as tool_count
FROM part p JOIN message m ON p.message_id = m.id JOIN session s ON m.session_id = s.id
WHERE p.type = 'tool'
GROUP BY m.session_id ORDER BY tool_count DESC LIMIT 10;"
# Total tokens used per session
sqlite3 /workspace/.local/share/opencode/opencode.db \
"SELECT session_id, s.title, SUM(tokens) as total_tokens
FROM message m JOIN session s ON m.session_id = s.id
GROUP BY session_id ORDER BY total_tokens DESC LIMIT 10;"
# Find sessions that modified a specific file
sqlite3 /workspace/.local/share/opencode/opencode.db \
"SELECT DISTINCT m.session_id, s.title
FROM part p JOIN message m ON p.message_id = m.id JOIN session s ON m.session_id = s.id
WHERE p.type = 'tool' AND p.tool = 'Write' AND p.input LIKE '%session.ts%';"
Tip: Always use read-only mode when exploring: sqlite3 -readonly /workspace/.local/share/opencode/opencode.db
3. REST API
Direct HTTP access to the OpenCode session API. Use via Kortix Master proxy (port 8000) or directly (port 4096).
# List all sessions
curl http://localhost:8000/session
# Get session metadata
curl http://localhost:8000/session/SESSION_ID
# Get session messages (raw, uncompressed)
curl http://localhost:8000/session/SESSION_ID/message
# Check what's running right now
curl http://localhost:8000/session/status
# Delete a session
curl -X DELETE http://localhost:8000/session/SESSION_ID
4. Grep/Ripgrep on Legacy JSON
Best for searching INSIDE message content across all sessions when you need exact keyword matches. Legacy JSON files mirror the SQLite data.
Storage layout:
/workspace/.local/share/opencode/storage/
├── session/global/ses_*.json # Session metadata (id, title, timestamps)
├── message/ses_*/msg_*.json # Messages per session (role, cost, tokens)
├── part/msg_*/prt_*.json # Content parts per message (text, tool calls, output)
└── todo/ses_*.json # Todo lists per session
Search Examples
# Find sessions mentioning "JWT" in their title
grep -rl '"title".*JWT' /workspace/.local/share/opencode/storage/session/global/
# Find which sessions used the Write tool
grep -rl '"tool":"Write"' /workspace/.local/share/opencode/storage/part/ | head -20
# Find tool calls that wrote to a specific file
grep -rl 'middleware/auth.ts' /workspace/.local/share/opencode/storage/part/
# Find sessions where an error occurred
grep -rl '"status":"error"' /workspace/.local/share/opencode/storage/part/
# Search message text content across all sessions
grep -rl 'database migration' /workspace/.local/share/opencode/storage/part/
# Count tool calls per session (rough)
for dir in /workspace/.local/share/opencode/storage/part/msg_*/; do
session=$(basename "$dir" | sed 's/msg_//')
count=$(grep -l '"type":"tool"' "$dir"prt_*.json 2>/dev/null | wc -l)
[ "$count" -gt 0 ] && echo "$count tool calls - $session"
done | sort -rn | head -10
When to use grep vs SQL: Use grep when you need to search inside raw tool outputs or message text that might not be indexed in SQLite columns. Use SQL for structured queries (costs, counts, joins).
5. Semantic Search (lss)
Use lss for meaning-based search when you don't know the exact keywords. lss combines BM25 full-text + embedding similarity.
# Search session files semantically
lss "authentication middleware implementation" -p /workspace/.local/share/opencode/storage/ -k 10 --json
# Scope to just session metadata
lss "database refactoring" -p /workspace/.local/share/opencode/storage/session/ -k 5 --json
# Scope to message parts (where the actual content lives)
lss "error handling for websockets" -p /workspace/.local/share/opencode/storage/part/ -k 10 --json
# Only search JSON files
lss "deployment config" -p /workspace/.local/share/opencode/storage/ -e .json -k 10 --json
When to use lss vs grep:
| Use lss | Use grep |
|---|---|
| Don't know exact keywords | Know the exact string |
| Conceptual search ("auth stuff") | Literal match ("tool":"Write") |
| Want ranked results by relevance | Want all matches |
| Searching natural language content | Searching structured JSON fields |
Storage Quick Reference
| What | Path |
|---|---|
| SQLite DB (primary) | /workspace/.local/share/opencode/opencode.db |
| Legacy JSON root | /workspace/.local/share/opencode/storage/ |
| Session metadata | storage/session/global/ses_*.json |
| Messages | storage/message/ses_*/msg_*.json |
| Parts (text, tool calls) | storage/part/msg_*/prt_*.json |
| Todos | storage/todo/ses_*.json |
| lss index | /workspace/.lss/ |
Combining Approaches
A typical deep session search workflow:
- session_list — scan titles to find candidate sessions
- session_get at 0.7 — quick compressed overview of each candidate
- session_get at 0.1 — full detail on the most relevant one
- grep on parts — find specific tool calls or outputs you need verbatim
- SQL — pull cost/token stats or cross-session aggregations
- lss — when you're not finding it by keyword, search by meaning
More from kortix-ai/kortix-registry
openalex-paper-search
Academic paper search powered by OpenAlex -- the free, open catalog of 240M+ scholarly works. Use when the user needs to find academic papers, research articles, literature for a topic, citation data, author publications, or any scholarly source. Triggers on: 'find papers on', 'academic research about', 'what studies exist', 'literature review', 'find citations', 'scholarly articles about', 'who published on', 'papers by [author]', 'highly cited papers on', any request for peer-reviewed or academic sources. Also use during deep research when you need to ground findings in academic literature. Do NOT use for general web searches -- use web-search for that.
202legal-writer
Legal document drafting -- contracts, memos, briefs, complaints, demand letters, opinions, discovery, settlements, ToS, privacy policies. Full pipeline: document structure, per-section writing, Bluebook citation, case law lookup (CourtListener API), regulation lookup (eCFR API), DOCX output, and TDD-style verification (defined terms, cross-references, placeholders, boilerplate, citation format). Triggers on: 'draft a contract', 'write a legal memo', 'create an NDA', 'write a brief', 'legal document about', 'draft a complaint', 'terms of service', 'privacy policy', 'demand letter', 'settlement agreement', 'legal opinion', 'discovery requests', any request to produce a legal or law-related document.
58paper-creator
Scientific paper writing in LaTeX -- full pipeline from structure to compiled PDF. TDD-driven: every section is compiled and verified before moving to the next. Covers project scaffolding, citation management (OpenAlex to BibTeX), per-section academic writing with self-reflection, figure/table inclusion, LaTeX compilation, and comprehensive verification. Triggers on: 'write a paper', 'create a paper', 'academic paper about', 'scientific paper', 'LaTeX paper', 'write up results as a paper', 'draft a paper on', 'research paper about', any request to produce a formal academic/scientific paper in LaTeX. Assumes research findings, data, and/or figures already exist or will be provided -- this skill handles the WRITING, not the experimentation.
11deep-research
Deep research agent skill. Use when the user needs thorough, scientific, truth-seeking research on any topic -- investigating claims, finding primary sources, synthesizing evidence, producing cited reports. Triggers on: 'research this', 'investigate', 'deep dive', 'find sources', 'what does the evidence say', 'literature review', 'fact check', 'analyze the research on', any request requiring multi-source investigation with citations.
10memory-context-management
Memory, context, and persistent knowledge management for the Kortix agent. Covers: kortix-sys-oc-plugin (observations, LTM consolidation, mem_search, mem_save, session_list, session_get), filesystem persistence rules, using .MD files for plans/notes/project state, how filesystem writes feed the memory pipeline, and best practices for ensuring nothing important is ever lost. Load this skill when you need to: understand how your memory works, decide where to persist information, write plans or notes, manage project context across sessions, or optimize your context window usage.
8domain-research
Free domain research and availability checking. No API keys or credentials required. Uses RDAP (1195+ TLDs) with whois CLI fallback for universal coverage. Checks if domains are available, searches keywords across TLDs, performs WHOIS/RDAP lookups, checks expiry dates, and finds nameservers. Use when the agent needs to: check if a domain is available, search for domains, find who owns a domain, check domain expiration, get nameservers, bulk check domains, or do any domain research. Triggers on: 'check domain', 'is domain available', 'search domains', 'domain availability', 'who owns this domain', 'whois', 'domain expiry', 'when does domain expire', 'nameservers for', 'domain research', 'find domains for', 'domain ideas', 'bulk domain check'.
7