From 59f4d7f089ebb001df4380f304fb4caa51c0cf18 Mon Sep 17 00:00:00 2001 From: ComputelessComputer <63365510+ComputelessComputer@users.noreply.github.com> Date: Fri, 26 Jun 2026 18:12:32 +0900 Subject: [PATCH] Search notes for unattached chat questions Guide chat to search local meeting notes for open-ended factual questions when no context is attached. --- apps/desktop/src/chat/tools/note-files.ts | 2 +- apps/desktop/src/chat/tools/search-sessions.ts | 1 + .../src/chat/transport/use-transport.test.ts | 16 ++++++++++++++++ apps/desktop/src/chat/transport/use-transport.ts | 8 +++++--- 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 apps/desktop/src/chat/transport/use-transport.test.ts diff --git a/apps/desktop/src/chat/tools/note-files.ts b/apps/desktop/src/chat/tools/note-files.ts index bdb4dfb4dc..3d9329e5f6 100644 --- a/apps/desktop/src/chat/tools/note-files.ts +++ b/apps/desktop/src/chat/tools/note-files.ts @@ -558,7 +558,7 @@ export const buildReadNoteTool = (deps: ToolDependencies) => export const buildGrepNotesTool = (deps: ToolDependencies) => tool({ description: - "Lexically search local note files and transcripts. Use this for find/search requests before answering from memory. This is filesystem-backed text search, not vector search.", + "Lexically search local note files and transcripts for exact words or phrases. Use search_sessions first for open-ended questions about past meetings, people, decisions, or topics. This is filesystem-backed text search, not vector search.", inputSchema: z.object({ query: z.string().describe("Text to search for in note files"), sessionIds: z diff --git a/apps/desktop/src/chat/tools/search-sessions.ts b/apps/desktop/src/chat/tools/search-sessions.ts index eb4614e637..484661be49 100644 --- a/apps/desktop/src/chat/tools/search-sessions.ts +++ b/apps/desktop/src/chat/tools/search-sessions.ts @@ -105,6 +105,7 @@ export const buildSearchSessionsTool = (deps: ToolDependencies) => tool({ description: ` Search for sessions (meeting notes) using query and filters. +Use this first for open-ended questions about past meetings, people, decisions, or topics when the answer may be in meeting notes and no meeting note context is attached. Use filters.created_at.kind="relative" with recent_days for natural-language date ranges. Use an empty query string when the user only wants sessions by date/time filter. Returns relevant sessions with their content. diff --git a/apps/desktop/src/chat/transport/use-transport.test.ts b/apps/desktop/src/chat/transport/use-transport.test.ts new file mode 100644 index 0000000000..4578670d6a --- /dev/null +++ b/apps/desktop/src/chat/transport/use-transport.test.ts @@ -0,0 +1,16 @@ +import { describe, expect, it } from "vitest"; + +import { appendFileContextToolGuidance } from "./use-transport"; + +describe("chat transport prompt guidance", () => { + it("tells chat to search meeting notes when no meeting note context is attached", () => { + const prompt = appendFileContextToolGuidance("Base prompt"); + + expect(prompt).toContain("Base prompt"); + expect(prompt).toContain("When no meeting note context is attached"); + expect(prompt).toContain("use search_sessions"); + expect(prompt).toContain( + "Do not ask the user to open or share a meeting note", + ); + }); +}); diff --git a/apps/desktop/src/chat/transport/use-transport.ts b/apps/desktop/src/chat/transport/use-transport.ts index b288523ee1..87612850ac 100644 --- a/apps/desktop/src/chat/transport/use-transport.ts +++ b/apps/desktop/src/chat/transport/use-transport.ts @@ -13,11 +13,13 @@ import { useToolRegistry } from "~/contexts/tool"; import { useConfigValue } from "~/shared/config"; import * as main from "~/store/tinybase/store/main"; -const FILE_CONTEXT_TOOL_GUIDANCE = ` +export const FILE_CONTEXT_TOOL_GUIDANCE = ` Context and local-note tool guidance: +- When no meeting note context is attached and the user asks a factual question that could be answered by meeting notes, use search_sessions with the key names, topics, and date hints before answering. If the result looks relevant, answer from the returned meeting context or call read_note with the returned session id for more detail. - When the user asks about "this note", "this meeting", "the current note", or pronouns that likely refer to the open note, use read_current_note before answering. -- When the user asks to find or search for something in notes, use grep_notes. If the answer needs the full source after a match, use read_note with the returned session id. +- When the user asks to find or search for exact wording in notes, use grep_notes. If the answer needs the full source after a match, use read_note with the returned session id. - When the user asks about people from the current note or related meetings, use list_related_notes and then read_note as needed. +- Do not ask the user to open or share a meeting note until search_sessions, grep_notes, or read_note cannot find enough local context. - Do not assume note contents from chat history when a file-backed tool can read the current source of truth. Web search guidance: @@ -26,7 +28,7 @@ Web search guidance: - Do not use web_search for questions that only need local notes, contacts, or calendar events. `.trim(); -function appendFileContextToolGuidance( +export function appendFileContextToolGuidance( prompt: string | undefined, ): string | undefined { if (prompt === undefined) {