Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 回忆指引截断分支不再先断言清单外命中一律无关
zqchrisae6ff9bdb2f3
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/agentHandoff.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/agentHandoff.test.tsindex b9fa1e14c8..97a7096b2d 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/agentHandoff.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/agentHandoff.test.ts@@ -142,6 +142,9 @@ describe('buildHandoffText', () => {});expect(truncated).toContain('The host could list only your newest 50 chats');expect(truncated).toContain('search once more without session_ids and treat any hit as possibly yours but unverified');+ // 截断分支不再先断言"清单外一律无关"——那会和"更早的自有对话存在"互斥;改为"可能是旧对话也可能无关"。+ expect(truncated).toContain('may be an older chat of yours or an unrelated task');+ expect(truncated).not.toContain('hits from sessions outside that list are unrelated context');// 宿主没给清单:只认当前对话。防御性上限 = 工具单次 session_ids 上限 50。const alone = buildHandoffText(messages, { ...opts, sessionId: 's-bot', reason: 'native-session-recovery', companion: true });expect(alone).toContain('"session_ids":["s-bot"]}');diff --git a/apps/desktop/src/main/maker-ipc/agentHandoff.ts b/apps/desktop/src/main/maker-ipc/agentHandoff.tsindex 3d16b76eba..097cb00236 100644--- a/apps/desktop/src/main/maker-ipc/agentHandoff.ts+++ b/apps/desktop/src/main/maker-ipc/agentHandoff.ts@@ -856,10 +856,10 @@ function assembleHandoffText(`== Recalling earlier history (use when needed) ==\n` +`Session id: ${opts.sessionId}\n` +`This is your long-running chat with the user. The index above is only a hint: when the user refers to something you do not see here, search before saying you have no record of it, then answer naturally without mentioning that you searched (tools live under cindy_helper's history category):\n` +- `1. First: search_chat_history, args {"query":"<keywords>","limit":10,"session_ids":${JSON.stringify(ownSessionIds)}}. Those session_ids are your own history as recorded by the host (this chat and your earlier chats before a restart first, then the background tasks you started) — keep them so the search stays within it. Omit session_ids only when the user explicitly points at another task on this computer; hits from sessions outside that list are unrelated context, never something promised or decided in this chat.${+ `1. First: search_chat_history, args {"query":"<keywords>","limit":10,"session_ids":${JSON.stringify(ownSessionIds)}}. Those session_ids are your own history as recorded by the host (this chat and your earlier chats before a restart first, then the background tasks you started) — keep them so the search stays within it.${opts.companionSessionIdsTruncated- ? ` The host could list only your newest ${COMPANION_SESSION_IDS_LIMIT} chats; older chats of yours exist beyond that list. If the user refers to something older and the scoped search finds nothing, search once more without session_ids and treat any hit as possibly yours but unverified: confirm with the user before relying on it.`- : ''+ ? ` The host could list only your newest ${COMPANION_SESSION_IDS_LIMIT} chats; older chats of yours exist beyond that list, so a hit from a session outside the list may be an older chat of yours or an unrelated task — you cannot tell which from the hit alone. If the user refers to something older and the scoped search finds nothing, search once more without session_ids and treat any hit as possibly yours but unverified: confirm with the user before relying on it, and never present it as something promised or decided here on your own authority.`+ : ` Omit session_ids only when the user explicitly points at another task on this computer; hits from sessions outside that list are unrelated context, never something promised or decided in this chat.`}\n` +`2. Only if that is not enough, read around the hit, anchored on the hit's sessionId and createdAt (get_chat_history returns the newest rows first by default, so without the anchor you would read the end of that session instead of the hit): get_chat_history, args {"session_ids":["<sessionId of the hit>"],"from":"<createdAt of the hit>","order":"asc","roles":["user","assistant"],"limit":20} for what followed, or {"session_ids":["<sessionId of the hit>"],"to":"<createdAt of the hit>","order":"desc","roles":["user","assistant"],"limit":20} for what came before. A wider excerpt is also available by repeating step 1 with "context_radius":6.\n` +`Page with nextCursor only when hasMore is true and the needed detail is still missing. Never request the default 200-row page and never dump the full history.\n` +