三只貓
Rich Mindset Zone
richmindsetzone.com
← All posts

記憶即新 RAG:Screenpipe 如何改變 AI Agent 的記憶架構

呢一年,每個整 AI Agent 嘅人都面對同一個矛盾:模型越嚟越聰明,但佢哋嘅記憶仍然停留喺「用完即棄」嘅階段。Claude 可以寫出一份完整嘅市場分析,GPT-4 可以 debug 成個 codebase,但當你開一個新 session,佢哋對你上個禮拜睇過邊份 competitor report、邊個 pricing page 令你改變策略——呢啲全部清零。Context window 由 8K 擴到 128K 再到 1M token,但呢個 scaling 策略治標不治本。每次新 session 仍然係一個全新嘅人。呢個唔係模型能力問題——呢個係記憶 architecture 問題。

RAG 嘅隱形天花:檢索唔等於記憶

傳統 RAG(Retrieval-Augmented Generation)嘅做法係:預先將文件切碎、embed、存入 vector DB,然後每次 query 嘅時候做 similarity search,拎返最 relevant 嘅 chunks。呢個 pattern 喺 QA bot 同客服系統上好 work,但作為 AI Agent 嘅「長期記憶」嚟講,有幾個根本缺陷。

第一,RAG 係 query-driven 嘅。你一定要知道自己想搵乜,先至會去 retrieve。但人類記憶唔係咁運作——你唔會每次諗嘢之前都 keyword search 一次。記憶係 context-triggered 嘅:你見到某個畫面、聽到某句說話,自然會聯想到相關經驗。Agent 需要嘅係 associative memory,唔係 search engine。

第二,RAG 嘅 chunks 係離散嘅。一份文件俾你切碎之後,similarity search 只係拎返表面上最似嘅幾塊碎片。Chunk size、overlap、embedding model 呢啲 hyperparameters 直接決定 retrieval quality,但無論點 tune,你都永遠 lost 咗 cross-chunk 嘅 context。第三,RAG 嘅更新係 batch 嘅。你要重新 embed、重新 index,先至可以加入新知識。但人類嘅記憶係 incremental 嘅——你睇完一篇新文章,唔使重新訓練個腦先記得佢。呢三個限制加埋,令傳統 RAG 更加似一個 document search system,而唔係一個 memory system。

Screenpipe 嘅做法完全唔同:佢唔係「你要 search 先有記憶」,而係「你一路做嘢,記憶一路自動形成」。

Screenpipe:唔係錄影機,而係記憶作業系統

Screenpipe 外表似係一個 24/7 螢幕錄影工具,但佢真正創新嘅係底層架構。唔好俾「錄影」呢兩個字誤導——佢唔係不斷 write frames 落 disk。佢係 event-driven 嘅:detect 到 app switch、click、typing pause、scroll 呢啲 meaningful events 先 capture。CPU 佔用維持喺 5-10%,RAM 0.5-3GB,一個月 storage 大約 20GB。呢個效率令到 continuous capture 真正可行,而唔係拖慢你部機嘅背景程式。

更關鍵嘅係 extraction pipeline。Screenpipe 唔係只係錄低你個螢幕,佢係 capture 成個 accessibility tree——即係個 OS 已經知道嘅 structured text:buttons、labels、text fields。Accessibility tree coverage 唔到嘅地方(remote desktop、game)先用 OCR fallback。同時佢用本地 Whisper 做 audio transcription,支援 speaker diarization。所以你唔係得張 screenshot——你有一個多模態嘅、time-indexed 嘅 lifetime activity log。

呢個就係核心 insight:傳統 RAG 要你預先決定「咩係值得儲嘅知識」,然後先 embed、先 index。Screenpipe 唔需要你決定——佢乜都 capture,然後用自然語言 search 做 retrieval。呢個 shift 係由「curated knowledge base」轉向「raw experience → on-demand retrieval」,同人類記憶嘅運作方式一致得多。你唔需要事先分類、tag、整理——你只需要 record,然後問問題。

逐條 Code:將 Screenpipe 變成 Agent 嘅海馬體

技術層面,Screenpipe 提供咗幾個接入點,由淺入深。最基本係 REST API,default 行 localhost:3030。Search endpoint 係最常用嘅:

GET http://localhost:3030/search?q=meeting+notes&content_type=all&limit=10

呢個 call 會同時 search screen text 同 audio transcription,return 埋 timestamp 同 screenshot reference。對 Agent 嚟講,呢個等於 instant replay——唔係搵 document,而係搵「當時我睇緊咩嘢同聽緊咩嘢」。用 JavaScript SDK 更直接:

import { pipe } from "@screenpipe/js";

const results = await pipe.queryScreenpipe({
  q: "project deadline",
  contentType: "all",
  limit: 20,
  startTime: new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString(),
});

呢個 pattern 嘅威力在於:作為 developer,你唔需要事先諗好用家可能會問咩問題。唔使 define schema、唔使 design data model、唔使諗點樣 chunk documents。你只需要俾 Agent 一個 function call,佢就可以 access 你過去所有 screen activity——跨越 app、跨越 browser tab、跨越時間。呢種 flexibility 係傳統 RAG pipeline 做唔到嘅。

仲有一個更靚嘅 integration 係 MCP server。一行 command:

claude mcp add screenpipe -- npx -y screenpipe-mcp@latest

之後你喺 Claude Desktop 可以直接問:「我頭先五個鐘睇過啲咩?」或者「今日嘅 meeting 有咩 action items?」Agent 唔係靠 prompt engineering 扮記得——佢真係有 source of truth 可以 query。對於 Cursor 或 VS Code 嘅 coding agent,呢個意味住佢哋可以 recall 你之前開過嘅 file、睇過嘅 error log、甚至係 Slack 上嘅 discussion thread,而唔係依賴 fading context window。

如果你想做更複雜嘅 automation,Screenpipe 嘅 Pipe system 係一個 scheduling layer:寫一個 markdown file 定義 prompt 同 schedule,Agent 就會定時 query 你嘅 screen data、call API、做 automation。呢個 architecture 比傳統 RAG pipeline 靈活得多,因為 data source 係 live 嘅,唔係一次過 pre-processed 就唔再更新。

下一步:共享記憶體與跨 Agent 生態

Screenpipe 解決咗「Agent 唔記得做過咩」嘅問題,但下一個問題係:唔同 Agent 之間點樣 share 記憶?如果你用 Claude Code 做 backend、Cursor 做 frontend、仲有一個 automation agent 做 DevOps——佢哋各自為政,每個都有自己嘅「失憶症」。

呢個就係 Agent Shadow Brain 嘅切入點。Shadow Brain 係一個 shared local memory layer,俾 Claude Code、Cursor、Cline、OpenCode、Aider 等 10+ coding agents 共享同一份記憶。佢嘅 Sub-Agent Brain Bridge (SABB) 可以將 brain context inject 落 sub-agent,而 Causal Memory Chains 令每項決策都 link 返個 cause——呢個層次嘅記憶架構已經超越咗單純嘅 RAG,進入咗 graph-based memory 嘅領域。

另一個值得留意嘅係 Obsidian Second Brain,一個跨 CLI 嘅 Obsidian skill,將你嘅 vault 變成 AI-first second brain。佢嘅 auto-synthesis 功能可以自動 cross-reference 唔同 sources 搵 patterns——呢個其實係 Screenpipe 理念喺 note-taking 領域嘅延伸:唔係你手動整理知識,而係 AI 自動幫你連接 dots。

呢三個 project 指向同一個趨勢:AI Agent 嘅記憶 architecture 正由「stateless RAG」邁向「stateful experience substrate」。Screenpipe 提供 raw experience layer(你做過咩、睇過咩、聽過咩),Shadow Brain 提供 cross-agent context layer(唔同 agents 共享同一份記憶),Obsidian Second Brain 提供 knowledge synthesis layer(將 experience 提煉成結構化知識)。三層加埋,先係完整嘅記憶系統。

如果你係 developer 做 AI Agent,今日可以開始做嘅實驗好簡單:裝一個 Screenpipe 行 background、connect MCP、然後叫你嘅 Agent 查返自己之前做過嘅 tasks。你會發現,當 Agent can access 自己嘅「過去」,佢嘅 output quality 會跳一個 level——因為佢唔再需要靠 context window 嚟記嘢,佢有咗真正嘅 memory substrate。呢個 shift,比起更大嘅 context window 或者更勁嘅 prompt engineering,可能先係令 AI Agent 真正變有用嘅關鍵。