fix: AI assistant in note-input still searches other notes when scoped to "this note"
When chatScope is "this note", the AI had access to note_search and note_read tools which let it pull content from any note. Now these tools are excluded via a webOnly flag in buildToolsForChat — only web_search/web_scrape remain if the user toggled web search. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -419,7 +419,11 @@ Never switch to another language. Even if the user writes in a different languag
|
||||
webSearch: !!webSearch,
|
||||
config,
|
||||
}
|
||||
const chatTools = toolRegistry.buildToolsForChat(chatToolContext)
|
||||
// When scoped to "this note", only provide web tools — no note_search/note_read
|
||||
// to prevent the AI from pulling information from other notes
|
||||
const chatTools = noteContext
|
||||
? toolRegistry.buildToolsForChat({ ...chatToolContext, webOnly: true })
|
||||
: toolRegistry.buildToolsForChat(chatToolContext)
|
||||
|
||||
// 8. Save user message to DB before streaming
|
||||
if (isNewMessage && lastIncoming) {
|
||||
|
||||
@@ -49,9 +49,10 @@ class ToolRegistry {
|
||||
/**
|
||||
* Build tools for the chat endpoint.
|
||||
* Includes internal tools (note_search, note_read) and web tools when configured.
|
||||
* When webOnly is true, only web tools are included (no note access).
|
||||
*/
|
||||
buildToolsForChat(ctx: ToolContext): Record<string, any> {
|
||||
const toolNames: string[] = ['note_search', 'note_read']
|
||||
buildToolsForChat(ctx: ToolContext & { webOnly?: boolean }): Record<string, any> {
|
||||
const toolNames: string[] = ctx.webOnly ? [] : ['note_search', 'note_read']
|
||||
|
||||
// Add web tools only when user toggled web search AND config is present
|
||||
if (ctx.webSearch) {
|
||||
|
||||
Reference in New Issue
Block a user