引言這份教學幫你把 Custom GPT 打造成「有長期記憶、會持續增長」的 2nd Brain 個人知識助理。
分工很簡單:Letta Cloud(前身 MemGPT)負責「有狀態代理+長短期記憶」、Exa AI 提供「即時權威網搜/抓取」、Custom GPT Actions 負責把用戶原話原封不動交給 Letta。系統會自動走 多層搜尋(Semantic → Archival → Web/Exa),並在回覆中給出 C|O|D|E 行動(Capture/Organize/Distill/Express),完成 收、理、煉、出。
本文提供一份可直接複製的 Instructions 與 Action Schema,並逐步說明 Letta Cloud 與 Custom GPT 的設置方法與常見問題。
by Adam Chan
ai-kb-json-k7f5xt3.gamma.site
別再用「人類摘要」餵 AI 了!打造高效企業知識庫的黃金準則(附 Prompt 可直接複製使用)
您是否曾感覺,與 AI 詳細解釋完一個專案的背景後,重新開啟新話題後,它就忘得一乾二淨。這正是所有大型語言模型(LLM)的共同限制:「上下文窗口」有限。 Letta(一個基於開創性的 MemGPT 概念所打造的系統)正是為了解決這個核心痛點而生。 您可以將 Letta 想像成一個為 AI 安裝的「外接大腦」。它模仿電腦操作系統管理記憶體的方式,為 AI 提供了兩種記憶體: 工作記憶 (Working Memory): 如同電腦的 RAM,小而快,用於處理當前的對話和任務。 長期記憶 (Long-term Memory): 如同電腦的硬碟,巨大且可供搜尋,用於存儲過去所有的對話、文件和知識。 Letta 的魔法在於,AI 學會了自主管理這兩層記憶。當遇到一個它不記得的問題時,它會自動去「搜尋」自己的長期記憶硬碟,找到最相關的資料,然後調閱到工作記憶中來回答您。 這項技術,讓一個健忘的聊天機器人,蛻變為一個能夠持續學習、真正擁有「記憶」的知識夥伴。
web_search_exa
等)。Authorization: Bearer <YOUR_LETTA_API_KEY>
;貼上 Schema(把 <YOUR_AGENT_ID>
改成你的)。semantic_search_files → (grep_files) → open_files → send_message
archival_memory_search
(找既有條目)、archival_memory_insert
(寫入)web_search_exa
(必要時才啟動)(實際鍵名content
/text
由系統偵測,這裡用<ARCHIVAL_INSERT_KEY>
代稱)
/execute_action action_type=archival_memory_insert payload={
"<ARCHIVAL_INSERT_KEY>":"《<主題>|Capture》\n來源:EXA/FILES/USER\n- 標題:<來源A 標題>\n URL:<來源A URL>\n 日期:<來源A 日期>\n- 標題:<來源B 標題>\n URL:<來源B URL>\n 日期:<來源B 日期>\n- 標題:<來源C 標題>\n URL:<來源C URL>\n 日期:<來源C 日期>"
}
/execute_action action_type=archival_memory_search payload={"query":"<主題>","limit":8}
/execute_action action_type=archival_memory_insert payload={
"<ARCHIVAL_INSERT_KEY>":"《<主題>|索引》\n相關條目:\n- <條目A>\n- <條目B>\n使用說明:如何瀏覽與維護"
}
/execute_action action_type=archival_memory_insert payload={
"<ARCHIVAL_INSERT_KEY>":"《<主題>|摘要》\n來源:PERSONAL/FILES/WEB\n- <來源1>\n- <來源2>\n摘要要點(3–8):\n1) …\n2) …\n差異/數據/日期:…\n分類(≤3):<AI 自行判斷的高階概念詞>"
}
/execute_action action_type=archival_memory_insert payload={
"<ARCHIVAL_INSERT_KEY>":"《<產物名稱>|Deliverable》\n<大綱/步驟/重點清單…>"
}
<<RAW>>...<<END>>
把用戶原話包起來,交到 Letta 的 /messages
端點agent-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
(📌重要︰用於 GPT 的 Action Schema 的 <YOUR_AGENT_ID> 內!) gpt-4o-mini
, GPT-4.1 nano
(Standard - 輕量快捷 ,基本測試用) 或 gpt-5
/ gemini 2.5 Pro preview
(Premium - 推理型) (相對穩定) ,補充︰semantic_search_files
, grep_files
, open_files
) 。semantic_search_files
:對已掛載文件做語義/向量檢索(全文層面),用於找出相似度最高的段落或文件。grep_files
:以關鍵詞/規則在文件內快速檢索(類似 grep),適合明確關鍵字情況。open_files
:開啟並讀取指定文件內容,供後續摘要或擷取。run_code
:在受控環境執行代碼(如清洗、去重、解析),配合 D|Distill。archival_memory_search
:於 Archival Memory 內做標題/關鍵詞精確匹配與檢索。archival_memory_insert
:將新內容寫入 Archival Memory,以便之後能被語義檢索命中(C|Capture 會用到)。conversation_search
:在代理的對話記憶中檢索歷次互動內容。core_memory_replace
:替換核心記憶項(更新既有條目)。core_memory_append
:追加核心記憶項(增量補充)。send_message
:在代理內部進行訊息傳遞(通常由代理流程自調)。web_search_exa
:即時網絡搜尋,回傳來源與摘錄。crawling_exa
:抓取指定 URL 內容並整理結構化資訊。company_research_exa
:對公司資訊做彙整(供研究情境)。Exa
(可自定,但建議簡潔一致)https://mcp.exa.ai/mcp
Access Token / API Key
(輸入你的 Exa API Key)web_search_exa
、crawling_exa
、company_research_exa
)並按 「Attach tool to Agent」附加到 Agent 。Required Before Exit: open_files
+ Continue Loop
Start Constraint
+ Constrain Child Tools
semantic_search_files
後只允許 grep/open
,不會亂跳。Continue Loop
semantic_search_files / grep_files
不准結束。Max Count
semantic=1 / grep=1 / open=1
,穩定且可預期。open_files
成為回覆前置,答案確實基於檔案內容。semantic_search_files
semantic_search_files → grep_files, open_files, conversation_search
grep_files → open_files, conversation_search
conversation_search → archival_memory_search
open_files → send_message, archival_memory_insert
archival_memory_insert → send_message
archival_memory_search → send_message, web_search_exa
semantic_search_files, grep_files, conversation_search, archival_memory_search
memory_insert, memory_replace
)send_message
semantic_search_files=1, grep_files=1, open_files=1
semantic_search_files → (grep_files)
;open_files → (send_message / +archival_memory_insert → send_message)
conversation_search → archival_memory_search → (send_message 或 web_search_exa)
Authorization: Bearer
<YOUR_LETTA_API_KEY>)。2nd Brain 個人知識助理(Letta × Exa)
這是一個專為個人知識管理與檢索設計的 AI 介面。所有回應一律經由 Letta Cloud 的 PersonalBrain_RAGAgent 處理;必要時由該 Agent(非 Actions 層)調用 Letta Cloud 內建工具與你已接上的 Exa AI MCP 工具進行公開網頁搜尋或抓取。 系統按 CODE 模式(Capture / Organize / Distill / Express)給出可執行建議。
Instructions 功能說明︰
Letta Agent 內部執行多層搜尋 🔎 Semantic 層:針對已掛載之文件做全文向量檢索,用於語義與段落級命中。 📜 Archival 層:於 Archival Memory 進行標題/關鍵詞精確匹配,命中長期筆記。 🌏 Web 層(Exa MCP):當內部兩層無命中時,由 web_search_exa/crawling_exa/company_research_exa 執行外部搜尋/抓取。 輸出與可操作性 🧩 來源分離:回覆嚴格分為 [PERSONAL](個人庫)與 [WEB](外部來源),避免混淆。 🧰 C/O/D/E 可執行命令:系統在 [CODE|NEXT STEPS] 自動生成對應動作的指令(含 /execute_action 與等效 alias)。 🧠 Capture(/collect):對於外部或新輸入內容,一鍵寫入 Archival;寫入後立即進向量索引,下次可由 Semantic 直接命中。 與實際 Instructions 的對應‧ sendMessageToPersonalBrainAgent:保證「用戶原話」直送代理。‧ 多層搜尋條款:對應「Semantic → Archival → Web/Exa」的順序與觸發條件。‧ 來源分離與鏈接規則:對應 [PERSONAL] / [WEB] 與 URL 驗證指引。‧ C/O/D/E:對應 /collect、/organize、/distill、/express 與自動產生命令。
(即常用的預置提問,按實際使用習慣而自由設置,如︰告訴我當前 Instructions 是什麼版本?)
API Key
Authorization: Bearer
<YOUR_LETTA_API_KEY> (這裡輸入 Letta Cloud 的 API Key 令 GPT 與 Letta 連結)請把下文 JSON schema 內的 "/v1/agents/<YOUR_AGENT_ID>/messages" 中的 <YOUR_AGENT_ID> 改為你自己的 Agent ID (見圖,可以在 Letta Cloud 的 Agents 頁內,左上方的 Name 下方找到 ID) (例如︰"/v1/agents/agent-4062181e-5xxx-4xxx-axxx-exxxxxxxxxxxx/messages") ;其餘保持不變。 operationId:sendMessageToPersonalBrainAgent
(必須與 Instructions 一致)
{
"openapi": "3.1.0",
"info": {
"title": "Personal Brain Assistant Actions",
"version": "v1.1.28-DeliveryFix",
"description": "Letta-first + Delivery 修復:/messages 設為 consequential;請求建議攜帶 use_assistant_message、include_return_message_types、return_actions 以確保把 Letta 生成結果帶回 GPT。"
},
"servers": [{ "url": "https://api.letta.com" }],
"security": [{ "LettaBearerAuth": [] }],
"paths": {
"/v1/agents/<YOUR_AGENT_ID>/messages": {
"post": {
"summary": "Send a message to the Personal Brain Agent",
"operationId": "sendMessageToPersonalBrainAgent",
"security": [{ "LettaBearerAuth": [] }],
"x-openai-isConsequential": true,
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/SendMessageRequest" }
}
}
},
"responses": {
"200": {
"description": "Successful response from Letta Agent",
"content": {
"application/json": { "schema": { "$ref": "#/components/schemas/AgentResponse" } }
}
}
}
}
},
"/v1/tools": {
"get": {
"summary": "List all available tools (Letta Cloud, MCP, Custom)",
"operationId": "listTools",
"security": [{ "LettaBearerAuth": [] }],
"x-openai-isConsequential": false,
"responses": {
"200": {
"description": "Organization-level tools",
"content": {
"application/json": { "schema": { "$ref": "#/components/schemas/ToolListResponse" } }
}
}
}
}
},
"/v1/agents/<YOUR_AGENT_ID>/tools": {
"get": {
"summary": "List tools attached to the agent",
"operationId": "listAgentTools",
"security": [{ "LettaBearerAuth": [] }],
"x-openai-isConsequential": false,
"responses": {
"200": {
"description": "Tools currently attached to the agent",
"content": {
"application/json": { "schema": { "$ref": "#/components/schemas/ToolListResponse" } }
}
}
}
}
},
"/v1/tools/add-base-tools": {
"post": {
"summary": "Upsert Base Tools (idempotent)",
"operationId": "upsertBaseTools",
"security": [{ "LettaBearerAuth": [] }],
"x-openai-isConsequential": false,
"responses": {
"200": {
"description": "Base tools upserted",
"content": {
"application/json": {
"schema": { "type": "array", "items": { "$ref": "#/components/schemas/ToolItem" } }
}
}
}
}
}
}
},
"components": {
"securitySchemes": {
"LettaBearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" }
},
"schemas": {
"SendMessageRequest": {
"type": "object",
"required": ["messages"],
"properties": {
"messages": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"required": ["role", "content"],
"properties": {
"role": { "type": "string", "enum": ["user"] },
"content": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"required": ["type", "text"],
"properties": {
"type": { "type": "string", "enum": ["text"] },
"text": {
"type": "string",
"description": "前置 [DIRECTIVE](Semantic→Archival→Web + C/O/D/E 決策與鏡射對照)+ 用戶原話(<<RAW>>…<<END>>)。"
}
}
}
}
}
}
},
"use_assistant_message": {
"type": "boolean",
"description": "要求 Letta 以 assistant_message 形態回傳可視文本(建議 true)。",
"default": true
},
"max_steps": { "type": "integer", "description": "Agent 最大步數(建議 50)" },
"search_strategy": { "type": "string", "enum": ["default", "multi_layer"] },
"return_actions": {
"type": "boolean",
"description": "是否同時回傳 action_suggestions(建議 true)。",
"default": true
},
"include_return_message_types": {
"type": "array",
"items": { "type": "string" },
"description": "建議包含:assistant_message、tool_call_message、tool_return_message。",
"default": ["assistant_message","tool_call_message","tool_return_message"]
},
"verbatim_mode": { "type": "boolean", "default": true }
},
"additionalProperties": true
},
"AgentResponse": {
"type": "object",
"properties": {
"messages": { "type": "array", "items": { "type": "object" } },
"action_suggestions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"label": { "type": "string" },
"action_type": { "type": "string" },
"target_id": { "type": "string" },
"api_endpoint": { "type": "string" },
"payload": { "type": "object" },
"command_string": { "type": "string" }
}
}
}
},
"additionalProperties": true
},
"ToolListResponse": { "type": "array", "items": { "$ref": "#/components/schemas/ToolItem" } },
"ToolItem": {
"type": "object",
"properties": {
"id": { "type": "string" },
"name": { "type": "string" },
"tool_type": { "type": "string" },
"description": { "type": "string" },
"json_schema": { "type": "object", "additionalProperties": true },
"args_json_schema": { "type": "object", "additionalProperties": true },
"tags": { "type": "array", "items": { "type": "string" } },
"source_type": { "type": "string" },
"source_code": { "type": "string" },
"return_char_limit": { "type": "integer" }
},
"additionalProperties": true
}
}
}
}
sendMessageToPersonalBrainAgent
listAgentTools
(Agent 已綁定工具)upsertBaseTools
(把「基礎工具」上載/更新到組織層(Org Catalog),不代表已自動綁到 Agent。)upsertBaseTools
的 「Test」,如果能回覆圖中內容 (類似) 便表示 GPT 與 Letta 成功連接 🥳「AI 生成/修改 Actions Schema」的提示前置段落 (將以下內容交給 AI 🤖 會有助加快除錯/優化功能 😉 ) GPT Action Schema 通用規格要求︰(官方對齊+實戰版)
View more
輸入 Privacy policy 的網址
參考︰最小可用版(簡潔、合規起點) 隱私權政策(適用於「2nd Brain 個人知識助理」) 內容為一般資訊, 不構成法律意見 ;如需遵循 GDPR/UK GDPR/CCPA 等法規,請讓法務審閱後再行使用。 最後更新: 2025-08-11
本頁說明 <你的網站/品牌名稱>(下稱「我們」)如何處理你在使用本 Custom GPT(以下稱「本服務」)時產生的資料。 資料來源與用途 你於本服務輸入的文字(「用戶內容」)會由 OpenAI 處理,並透過已連接的 Letta Cloud(前身 MemGPT)代理進行檢索與回覆;在需要即時資料時,代理可能調用 Exa AI 進行網絡搜尋/抓取。 用戶內容的用途:依你的指示,於個人知識庫進行檢索、組織、摘要、生成可執行清單等。除非你主動要求,我們不會將用戶內容用作行銷。 第三方處理者 OpenAI:提供模型推理與「Custom GPT + Actions」。 Letta Cloud:提供狀態式代理、長短期記憶與語義檢索(可能含檔案系統與 Archival Memory)。 Exa AI:在代理決策需要時提供即時搜尋/抓取。 各第三方之資料使用,受其各自之條款與隱私政策約束。 保存與刪除 我們不另行販售或對外公開你的用戶內容。 保存期間視系統運作需求與第三方供應商之設定而定;你可依第三方機制請求刪除或在我們處提出刪除要求(若技術上可行)。 安全 我們採用 API 金鑰與最低必要權限原則;請避免在對話中輸入敏感個資與機密資訊。 使用者權利與聯絡方式 若你欲查詢、修正或刪除資料,請以電郵聯絡:<你的聯絡電郵>。 如政策修訂,我們將更新本頁「最後更新」日期。 聯絡人/負責單位:<你的公司/個人名稱>
GET /v1/tools
→ 如未見 send_message
/archival_memory_search
/semantic_search_files
(或 search_files
)/grep
/open
,立刻 POST /v1/tools/add-base-tools
,再 GET /v1/tools
確認。<關鍵字>
,取 2–3 條權威來源,每條 2–4 句摘錄並附連結。」/collect
、/organize
、/distill
、/express
等(或 /execute_action
原生命令),確認系統原封送入 Letta 並執行。"include_return_message_types": ["tool_call_message","tool_return_message","assistant_message"]
,回覆中可看到實際工具(例如 semantic_search_files
)的調用與回傳節點。<YOUR_AGENT_ID>
換成真實 Agent ID;Bearer <YOUR_LETTA_API_KEY>
;<<RAW>> ... <<END>>
裡,內容會原封送入 Letta。<<RAW>> 幫我把以下兩篇加入個人庫,之後做統整。 <<END>>
<<RAW>>
與 <<END>>
?/collect target_id=...
?「請把上面兩篇存入個人庫,加標籤:A/B。」
系統會自動產生可複製的命令並幫你執行,避免手動填target_id
出錯。
「把剛才那兩篇寫入個人庫(Archival),並回報成功。」
archival_memory_insert
之類的工具把內容寫入檔案層。)https://mcp.exa.ai/mcp
)→ 設定 API Key / Access Tokenweb_search_exa
(及需要的 crawling_exa
/ company_research_exa
)附加到你的 Agentweb_search_exa
/crawling_exa
/company_research_exa
→ Deploy。完成後重問一次即可。web_search
唔得,係用途唔同:web_search
走關鍵字/問答式,靠搜尋引擎收錄,回來多數係片段,啱快手搵參考;Exa 為 AI 而設,可直接提取網頁正文、輸出連引用的結構化結果,亦支援站內多層爬同多步研究,速度同穩定性更好。兩者都不會越過登入/付費牆;若要把資料存入知識庫(資料庫 / Archival Memory)重用、可追溯引用,選擇 Exa 更適合。target_id=<ID>
但你不知道那是什麼:不用理會,直接用自然語句「請幫我把上面兩篇存入個人庫」即可。Bearer <YOUR_LETTA_API_KEY>
;重新存檔後再問。<YOUR_AGENT_ID>
換成真的,或JSON 括號/逗號不匹配。ai-kb-json-k7f5xt3.gamma.site
別再用「人類摘要」餵 AI 了!打造高效企業知識庫的黃金準則(附 Prompt 可直接複製使用)
您是否曾感覺,與 AI 詳細解釋完一個專案的背景後,重新開啟新話題後,它就忘得一乾二淨。這正是所有大型語言模型(LLM)的共同限制:「上下文窗口」有限。 Letta(一個基於開創性的 MemGPT 概念所打造的系統)正是為了解決這個核心痛點而生。 您可以將 Letta 想像成一個為 AI 安裝的「外接大腦」。它模仿電腦操作系統管理記憶體的方式,為 AI 提供了兩種記憶體: 工作記憶 (Working Memory): 如同電腦的 RAM,小而快,用於處理當前的對話和任務。 長期記憶 (Long-term Memory): 如同電腦的硬碟,巨大且可供搜尋,用於存儲過去所有的對話、文件和知識。 Letta 的魔法在於,AI 學會了自主管理這兩層記憶。當遇到一個它不記得的問題時,它會自動去「搜尋」自己的長期記憶硬碟,找到最相關的資料,然後調閱到工作記憶中來回答您。 這項技術,讓一個健忘的聊天機器人,蛻變為一個能夠持續學習、真正擁有「記憶」的知識夥伴。