YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: improve AI context engineering for better tool selection and fewer wasted turns
Louis Beaumont67ef7ede0710
diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsxindex 1e66aa11a..48ea064c9 100644--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx@@ -92,42 +92,57 @@ function buildSystemPrompt(): string {return `You are a helpful AI assistant that can search through the user's Screenpipe data - their screen recordings, audio transcriptions, and UI interactions.-CRITICAL SEARCH RULES (database has 600k+ entries - ALWAYS use time filters):+BEHAVIOR RULES:+- Act immediately on clear requests. NEVER ask for confirmation when the user's intent is obvious.+- If a search returns empty, silently fix your query and retry (widen time range, remove filters). Do NOT list "possibilities" or ask the user what to do.+- Be concise. Cite timestamps when relevant. Convert all UTC timestamps to the user's local timezone before displaying.++TOOL SELECTION (use the right tool for the job):+- "meeting", "call", "conversation", "what did I/they say" → search with content_type: "audio", NO q param+- "how long", "time spent", "which apps", "most used" → use activity-summary (NOT raw frame counts or SQL)+- "what was on screen", "what was I reading/looking at" → search with content_type: "all" or "accessibility"+- Broad overview ("what was I doing?") → activity-summary FIRST, then drill into search-content++CRITICAL SEARCH RULES (database has 600k+ entries):1. ALWAYS include start_time in EVERY search - NEVER search without a time range2. Default time range: last 1-2 hours. Expand ONLY if no results found-3. First search: ONLY use time params (start_time, end_time). No q, no app_name, no content_type. This gives ground truth of what's recorded. Scan results to find correct app_name values, then narrow with filters using exact observed values. App names are case-sensitive and may differ from user input (e.g. "Discord" vs "Discord.exe" vs "discord"). The q param searches captured text (accessibility/OCR), NOT app names.+3. First search: ONLY use time params (start_time, end_time). No q, no app_name, no content_type. This gives ground truth of what's recorded. Scan results to find correct app_name values, then narrow with filters using exact observed values. App names are case-sensitive (e.g. "Discord" vs "Discord.exe"). The q param searches captured text, NOT app names.4. NEVER report "no data found" after one filtered search. Verify with unfiltered time-only search first.5. Keep limit=5-10 per search. NEVER use limit > 506. Maximum 10 search/API calls per user request. Stop and summarize what you have-7. For weekly/multi-day queries: search ONE DAY AT A TIME with small limits, never the full range at once-8. Prefer /raw_sql with COUNT(*), GROUP BY, and aggregation over fetching raw content rows-9. All /raw_sql SELECT queries MUST include a LIMIT clause (max 10000). The server will reject queries without LIMIT+7. For weekly/multi-day queries: search ONE DAY AT A TIME with small limits+8. Prefer /raw_sql with COUNT(*), GROUP BY for aggregation over fetching raw rows+9. All /raw_sql SELECT queries MUST include a LIMIT clause (max 10000)++EXAMPLES OF GOOD SEARCHES:+- User: "summarize my meeting" → search content_type:"audio", start_time:"2h ago", NO q param → summarize transcriptions+- User: "what apps did I use today" → call activity-summary with start_time: today_start, end_time: now → report active_minutes per app+- User: "what was I reading about X" → search q:"X", start_time:"3h ago" → show text with deep linksRules for showing videos/audio:- Show videos by putting .mp4 file paths in inline code blocks: \`/path/to/video.mp4\`- Use the exact, absolute file_path from search results-Be concise. Cite timestamps when relevant.-IMPORTANT: All timestamps from the API/database are in UTC. You MUST convert them to the user's local timezone (shown below) before displaying. For example, if the API returns "2024-01-15T13:00:00Z" and the user is in UTC+1, display "2:00 PM" not "1:00 PM".+SPEAKER MANAGEMENT (localhost:3030):+- GET /speakers/unnamed?limit=10 — list unnamed speakers+- GET /speakers/search?name=John — search by name+- POST /speakers/update — rename: {"id": 5, "name": "John"}+- POST /speakers/merge — merge duplicates: {"speaker_to_keep_id": 1, "speaker_to_merge_id": 2}+- GET /speakers/similar?speaker_id=5 — find similar speakers+- POST /speakers/reassign — reassign audio chunk to different speakerFULL API REFERENCE:-For the complete list of 60+ screenpipe API endpoints (frames, audio, vision, tags, speakers, pipes, streaming, etc.), fetch: https://docs.screenpi.pe/llms-full.txt-Only fetch this when you need endpoints beyond /search (e.g., tags, speakers, pipes, frames, audio control).+For the complete list of 60+ screenpipe API endpoints (frames, audio, pipes, tags, etc.), fetch: https://docs.screenpi.pe/llms-full.txt+Fetch this when you need endpoints beyond /search, /activity-summary, or /speakers.VISUALIZATION:-When the user asks for diagrams, flowcharts, or visualizations, generate Mermaid diagrams using fenced code blocks with the "mermaid" language tag. Example:-\`\`\`mermaid-graph TD- A[Start] --> B[Process]- B --> C[End]-\`\`\`-Use flowcharts (graph TD/LR), sequence diagrams, pie charts, etc. as appropriate.+When the user asks for diagrams, flowcharts, or visualizations, generate Mermaid diagrams using fenced code blocks with the "mermaid" language tag.DEEP LINKS & MEDIA:- Frame (PREFERRED): [10:30 AM — Chrome](screenpipe://frame/12345) — use frame_id from OCR search results. NEVER invent frame IDs.- Timeline (audio only): [meeting at 3pm](screenpipe://timeline?timestamp=2024-01-15T15:00:00Z) — use exact timestamp from audio search results.- Video: show .mp4 paths in inline code: \`/path/to/video.mp4\`-ALWAYS use screenpipe://frame/{frame_id} for OCR results. Only use screenpipe://timeline for audio results (no frame_id). Copy IDs/timestamps verbatim from search results — NEVER fabricate them.+NEVER fabricate frame IDs or timestamps — only use values from actual search results.Current time: ${now.toISOString()}User's timezone: ${timezone} (UTC${offsetStr})diff --git a/crates/screenpipe-core/assets/skills/screenpipe-analytics/SKILL.md b/crates/screenpipe-core/assets/skills/screenpipe-analytics/SKILL.mdindex a2e297d51..26fc81ba8 100644--- a/crates/screenpipe-core/assets/skills/screenpipe-analytics/SKILL.md+++ b/crates/screenpipe-core/assets/skills/screenpipe-analytics/SKILL.md@@ -56,8 +56,8 @@ CREATE TABLE frames (**Key facts:**- Frames are event-driven (accessibility captures fire on content change), NOT fixed-interval. Frame count does NOT reliably translate to screen time.-- For accurate time estimates, use the `/activity-summary` endpoint which uses gap-based duration (consecutive frames with gaps < 5min = active time).-- For raw SQL, approximate with gap analysis, NOT `COUNT(*) * 2 / 60` (which assumes fixed 0.5 fps and is wildly inaccurate).+- **WARNING: Do NOT use SQL to answer "how long" / "time spent" / "which apps did I use most" questions.** Use the `/activity-summary` REST endpoint instead — it calculates accurate active session time. SQL frame counts can be off by 10x.+- If you must use SQL for time estimation, use gap analysis (measure time between consecutive frames), NOT `COUNT(*) * 2 / 60`.- `app_name` is the focused application- `browser_url` is populated for browser windows- `window_name` contains document/tab titlesdiff --git a/crates/screenpipe-core/assets/skills/screenpipe-search/SKILL.md b/crates/screenpipe-core/assets/skills/screenpipe-search/SKILL.mdindex e48522147..e0bdd3a4c 100644--- a/crates/screenpipe-core/assets/skills/screenpipe-search/SKILL.md+++ b/crates/screenpipe-core/assets/skills/screenpipe-search/SKILL.md@@ -28,8 +28,8 @@ curl "http://localhost:3030/search?q=QUERY&content_type=all&limit=10&start_time=| Parameter | Type | Required | Description ||-----------|------|----------|-------------|-| `q` | string | No | Search keywords. Be specific. |-| `content_type` | string | No | `all` (default), `ocr`, `audio`, `input`, `accessibility` |+| `q` | string | No | Search keywords. Be specific. Do NOT use for audio/meeting searches — transcriptions are noisy, q filters too aggressively. |+| `content_type` | string | No | `all` (default), `ocr`, `audio` (use for meetings/calls), `input`, `accessibility` || `limit` | integer | No | Max results 1-20. Default: 10 || `offset` | integer | No | Pagination offset. Default: 0 || `start_time` | ISO 8601 or relative | **Yes** | Start of time range. ALWAYS include this. Accepts ISO 8601 (`2024-01-15T10:00:00Z`) or relative (`16h ago`, `2d ago`, `30m ago`). |@@ -63,10 +63,18 @@ Don't jump straight to heavy `/search` calls. Escalate through these steps, stop- "What was I doing?" → Step 1 only- "What did I work on in Chrome?" → Step 1 (identify Chrome usage) → Step 2 (search Chrome content)+- "Summarize my meeting/call" → Step 2 directly with `content_type=audio`, NO q param+- "How long did I spend on X?" → Step 1 (`/activity-summary` has accurate `active_minutes`)+- "Which apps did I use today?" → Step 1 (`/activity-summary` — do NOT use frame counts or SQL)- "What button did I click?" → Step 1 (context) → Step 3 (elements with role=AXButton)- "Show me what I was looking at" → Step 1 → Step 2 (find frame_id) → Step 4 (fetch screenshot)- "What URLs did I visit?" → Step 1 (identify browser) → Step 3 (`/frames/{id}/context` for URLs)+#### Common mistakes to avoid+- Do NOT use raw frame counts or SQL `COUNT(*)` on frames table to estimate time spent — it's wildly inaccurate. Use `/activity-summary` which calculates actual active session time.+- Do NOT use the `q` param when searching audio/meetings — transcriptions have noise/typos that cause q to miss relevant content. Search by time range and content_type=audio, then scan results.+- Do NOT ask the user for clarification when their intent is clear. "Summarize my meeting" → search audio immediately. "What apps today?" → call activity-summary immediately.+### CRITICAL RULES1. **ALWAYS include `start_time`** — the database has hundreds of thousands of entries. Queries without time bounds WILL timeout.diff --git a/crates/screenpipe-integrations/screenpipe-mcp/package.json b/crates/screenpipe-integrations/screenpipe-mcp/package.jsonindex e46b709a9..96664d3ae 100644--- a/crates/screenpipe-integrations/screenpipe-mcp/package.json+++ b/crates/screenpipe-integrations/screenpipe-mcp/package.json@@ -1,6 +1,6 @@{"name": "screenpipe-mcp",- "version": "0.8.4",+ "version": "0.8.5","description": "MCP server for screenpipe - search your screen recordings and audio transcriptions","main": "dist/index.js","bin": {diff --git a/crates/screenpipe-integrations/screenpipe-mcp/src/index.ts b/crates/screenpipe-integrations/screenpipe-mcp/src/index.tsindex a19ad8f35..cbf79bb5d 100644--- a/crates/screenpipe-integrations/screenpipe-mcp/src/index.ts+++ b/crates/screenpipe-integrations/screenpipe-mcp/src/index.ts@@ -48,7 +48,7 @@ const SCREENPIPE_API = `http://localhost:${port}`;const server = new Server({name: "screenpipe",- version: "0.8.3",+ version: "0.8.5",},{capabilities: {@@ -68,10 +68,14 @@ const BASE_TOOLS: Tool[] = ["Returns timestamped results with app context. " +"Call with no parameters to get recent activity. " +"Use the 'screenpipe://context' resource for current time when building time-based queries.\n\n" ++ "WHEN TO USE WHICH content_type:\n" ++ "- For meetings/calls/conversations: content_type='audio', do NOT use q param (transcriptions are noisy, q filters too aggressively)\n" ++ "- For screen text/reading: content_type='all' or 'accessibility'\n" ++ "- For time spent/app usage questions: use activity-summary tool instead (this tool returns content, not time stats)\n\n" +"SEARCH STRATEGY: First search with ONLY time params (start_time/end_time) — no q, no app_name, no content_type. " +"This gives ground truth of what's recorded. Scan results to find correct app_name values, then narrow with filters using exact observed values. " +- "App names are case-sensitive and may differ from user input (e.g. 'Discord' vs 'Discord.exe'). " +- "The q param searches captured text (accessibility/OCR), NOT app names. NEVER report 'no data' after one filtered search — verify with unfiltered time-only search first.\n\n" ++ "App names are case-sensitive (e.g. 'Discord' vs 'Discord.exe'). " ++ "The q param searches captured text, NOT app names. NEVER report 'no data' after one filtered search — verify with unfiltered time-only search first.\n\n" +"DEEP LINKS: When referencing specific moments, create clickable links using IDs from search results:\n" +"- OCR results (PREFERRED): [10:30 AM — Chrome](screenpipe://frame/12345) — use content.frame_id from the result\n" +"- Audio results: [meeting at 3pm](screenpipe://timeline?timestamp=2024-01-15T15:00:00Z) — use exact timestamp from result\n" +@@ -85,12 +89,12 @@ const BASE_TOOLS: Tool[] = [properties: {q: {type: "string",- description: "Search query. Optional - omit to return all recent content.",+ description: "Search query (full-text search on captured text). Optional - omit to return all content in time range. IMPORTANT: Do NOT use q for audio/meeting searches — transcriptions are noisy and q filters too aggressively. Only use q when searching for specific text the user saw on screen.",},content_type: {type: "string",enum: ["all", "ocr", "audio", "input", "accessibility"],- description: "Content type filter: 'ocr' (screen text via OCR, legacy fallback), 'audio' (transcriptions), 'input' (clicks, keystrokes, clipboard, app switches), 'accessibility' (accessibility tree text, preferred for screen content), 'all'. Default: 'all'.",+ description: "Content type filter: 'audio' (transcriptions — use for meetings/calls/conversations), 'accessibility' (accessibility tree text, preferred for screen content), 'ocr' (screen text via OCR, legacy fallback), 'input' (clicks, keystrokes, clipboard, app switches), 'all'. Default: 'all'. For meeting/call queries, ALWAYS use 'audio'.",default: "all",},limit: {@@ -229,9 +233,14 @@ const BASE_TOOLS: Tool[] = ["Get a lightweight compressed activity overview for a time range (~200-500 tokens). " +"Returns app usage (name, frame count, active minutes, first/last seen), recent accessibility texts, and audio speaker summary. " +"Minutes are based on active session time (consecutive frames with gaps < 5min count as active). " +- "first_seen/last_seen show the wall-clock span per app. " +- "Use this FIRST for broad questions like 'what was I doing?' before drilling into search-content or search-elements. " +- "Much cheaper than search-content for getting an overview.",+ "first_seen/last_seen show the wall-clock span per app.\n\n" ++ "USE THIS TOOL (not search-content or raw SQL) for:\n" ++ "- 'how long did I spend on X?' → active_minutes per app\n" ++ "- 'which apps did I use today?' → app list sorted by active_minutes\n" ++ "- 'what was I doing?' → broad overview before drilling deeper\n" ++ "- Any time-spent or app-usage question\n\n" ++ "WARNING: Do NOT estimate time from raw frame counts or SQL queries — those are inaccurate. " ++ "This endpoint calculates actual active session time correctly.",annotations: {title: "Activity Summary",readOnlyHint: true,@@ -424,6 +433,20 @@ Screenpipe captures four types of data:- **Get keyboard input**: \`{"content_type": "input"}\`- **Get audio only**: \`{"content_type": "audio"}\`+## Common User Requests → Correct Tool Choice+| User says | Use this tool | Key params |+|-----------|--------------|------------|+| "summarize my meeting/call" | search-content | content_type:"audio", NO q param, start_time |+| "what did they/I say about X" | search-content | content_type:"audio", NO q param (scan results manually) |+| "how long on X" / "which apps" / "time spent" | activity-summary | start_time, end_time |+| "what was I doing" | activity-summary | start_time, end_time (then drill into search-content) |+| "what was I reading/looking at" | search-content | content_type:"all", start_time |++## Behavior Rules+- Act immediately on clear requests. NEVER ask "what time range?" or "which content type?" when the intent is obvious.+- If search returns empty, silently retry with wider time range or fewer filters. Do NOT ask the user what to change.+- For meetings: ALWAYS use content_type:"audio" and do NOT use the q param. Transcriptions are noisy — q filters too aggressively and misses relevant content.+## search-content| Parameter | Description | Default ||-----------|-------------|---------|@@ -453,6 +476,15 @@ Screenpipe captures four types of data:Previous screenpipe chat conversations are stored as individual JSON files in ~/.screenpipe/chats/{conversation-id}.jsonEach file contains: id, title, messages[], createdAt, updatedAt. You can read these files to reference or search previous conversations.+## Speaker Management+screenpipe auto-identifies speakers in audio. API endpoints for managing them:+- \`GET /speakers/unnamed?limit=10\` — list unnamed speakers+- \`GET /speakers/search?name=John\` — search by name+- \`POST /speakers/update\` with \`{"id": 5, "name": "John"}\` — rename a speaker+- \`POST /speakers/merge\` with \`{"speaker_to_keep_id": 1, "speaker_to_merge_id": 2}\` — merge duplicates+- \`GET /speakers/similar?speaker_id=5\` — find similar speakers for merging+- \`POST /speakers/reassign\` — reassign audio chunk to different speaker+## Tips1. Read screenpipe://context first to get current timestamps2. Use activity-summary before search-content for broad overview questions