diff --git a/src/services/llm/pipeline/chat_pipeline.ts b/src/services/llm/pipeline/chat_pipeline.ts index 7b8822403..fc9f7bc8e 100644 --- a/src/services/llm/pipeline/chat_pipeline.ts +++ b/src/services/llm/pipeline/chat_pipeline.ts @@ -455,7 +455,7 @@ export class ChatPipeline { log.info(`========== TOOL EXECUTION RESULTS ==========`); log.info(`Received ${toolResultMessages.length} tool results`); toolResultMessages.forEach((msg, idx) => { - log.info(`Tool result ${idx + 1}: tool_call_id=${msg.tool_call_id}, content=${msg.content.substring(0, 100)}${msg.content.length > 100 ? '...' : ''}`); + log.info(`Tool result ${idx + 1}: tool_call_id=${msg.tool_call_id}, content=${msg.content}`); log.info(`Tool result status: ${msg.content.startsWith('Error:') ? 'ERROR' : 'SUCCESS'}`); log.info(`Tool result for: ${this.getToolNameFromToolCallId(currentMessages, msg.tool_call_id || '')}`); diff --git a/src/services/llm/prompts/base_system_prompt.md b/src/services/llm/prompts/base_system_prompt.md index 7827c957a..a353f21b7 100644 --- a/src/services/llm/prompts/base_system_prompt.md +++ b/src/services/llm/prompts/base_system_prompt.md @@ -12,6 +12,12 @@ You are an AI assistant integrated into TriliumNext Notes, a powerful note-takin Your primary goal is to help users find information in their notes, answer questions based on their knowledge base, and provide assistance with using TriliumNext Notes features. Be sure to summarize the notes and include the title of the notes when providing a summary. +IMPORTANT: When working with notes in TriliumNext: +- Each note has a unique system ID (e.g., "abc123def456") which is different from its title +- When tools require a noteId parameter, always use the system ID, not the title +- Always use search tools first to find notes and get their IDs before performing operations on them +- Using a note's title instead of its ID will cause operations to fail + When responding to queries: - For complex queries, decompose them into simpler parts and address each one - When citing information from the user's notes, mention the note title (e.g., "According to your note titled 'Project Ideas'...") diff --git a/src/services/llm/tools/attribute_manager_tool.ts b/src/services/llm/tools/attribute_manager_tool.ts index 5618b47ed..72032ac57 100644 --- a/src/services/llm/tools/attribute_manager_tool.ts +++ b/src/services/llm/tools/attribute_manager_tool.ts @@ -28,7 +28,7 @@ export const attributeManagerToolDefinition: Tool = { properties: { noteId: { type: 'string', - description: 'ID of the note to manage attributes for' + description: 'System ID of the note to manage attributes for (not the title). This is a unique identifier like "abc123def456".' }, action: { type: 'string', diff --git a/src/services/llm/tools/note_creation_tool.ts b/src/services/llm/tools/note_creation_tool.ts index d5f84df70..9633880e4 100644 --- a/src/services/llm/tools/note_creation_tool.ts +++ b/src/services/llm/tools/note_creation_tool.ts @@ -23,7 +23,7 @@ export const noteCreationToolDefinition: Tool = { properties: { parentNoteId: { type: 'string', - description: 'ID of the parent note under which to create the new note. If not specified, creates under root.' + description: 'System ID of the parent note under which to create the new note (not the title). This is a unique identifier like "abc123def456". If not specified, creates under root.' }, title: { type: 'string', diff --git a/src/services/llm/tools/note_summarization_tool.ts b/src/services/llm/tools/note_summarization_tool.ts index a9f35737c..bc5999e0c 100644 --- a/src/services/llm/tools/note_summarization_tool.ts +++ b/src/services/llm/tools/note_summarization_tool.ts @@ -23,7 +23,7 @@ export const noteSummarizationToolDefinition: Tool = { properties: { noteId: { type: 'string', - description: 'ID of the note to summarize' + description: 'System ID of the note to summarize (not the title). This is a unique identifier like "abc123def456".' }, maxLength: { type: 'number', @@ -183,4 +183,4 @@ export class NoteSummarizationTool implements ToolHandler { return text; } -} +} \ No newline at end of file diff --git a/src/services/llm/tools/note_update_tool.ts b/src/services/llm/tools/note_update_tool.ts index 6e9c90c01..0dc5fd723 100644 --- a/src/services/llm/tools/note_update_tool.ts +++ b/src/services/llm/tools/note_update_tool.ts @@ -22,7 +22,7 @@ export const noteUpdateToolDefinition: Tool = { properties: { noteId: { type: 'string', - description: 'ID of the note to update' + description: 'System ID of the note to update (not the title). This is a unique identifier like "abc123def456" that must be used to identify the specific note.' }, title: { type: 'string', diff --git a/src/services/llm/tools/read_note_tool.ts b/src/services/llm/tools/read_note_tool.ts index d128d550a..ddcad559f 100644 --- a/src/services/llm/tools/read_note_tool.ts +++ b/src/services/llm/tools/read_note_tool.ts @@ -40,7 +40,7 @@ export const readNoteToolDefinition: Tool = { properties: { noteId: { type: 'string', - description: 'The ID of the note to read' + description: 'The system ID of the note to read (not the title). This is a unique identifier like "abc123def456" that must be used to access a specific note.' }, includeAttributes: { type: 'boolean', diff --git a/src/services/llm/tools/relationship_tool.ts b/src/services/llm/tools/relationship_tool.ts index 7f8709dfa..09e16f72c 100644 --- a/src/services/llm/tools/relationship_tool.ts +++ b/src/services/llm/tools/relationship_tool.ts @@ -29,11 +29,11 @@ export const relationshipToolDefinition: Tool = { }, sourceNoteId: { type: 'string', - description: 'ID of the source note for the relationship' + description: 'System ID of the source note for the relationship (not the title). This is a unique identifier like "abc123def456".' }, targetNoteId: { type: 'string', - description: 'ID of the target note for the relationship (for create action)' + description: 'System ID of the target note for the relationship (not the title). This is a unique identifier like "abc123def456".' }, relationName: { type: 'string', diff --git a/src/services/llm/tools/search_notes_tool.ts b/src/services/llm/tools/search_notes_tool.ts index 8c048d76e..fbef8d776 100644 --- a/src/services/llm/tools/search_notes_tool.ts +++ b/src/services/llm/tools/search_notes_tool.ts @@ -25,7 +25,7 @@ export const searchNotesToolDefinition: Tool = { }, parentNoteId: { type: 'string', - description: 'Optional parent note ID to restrict search to a specific branch' + description: 'Optional system ID of the parent note to restrict search to a specific branch (not the title). This is a unique identifier like "abc123def456".' }, maxResults: { type: 'number', @@ -146,7 +146,8 @@ export class SearchNotesTool implements ToolHandler { preview: result.contentPreview, similarity: Math.round(result.similarity * 100) / 100, parentId: result.parentId - })) + })), + message: "Note: Use the noteId (not the title) when performing operations on specific notes with other tools." }; } catch (error: any) { log.error(`Error executing search_notes tool: ${error.message || String(error)}`); diff --git a/src/services/llm/tools/tool_interfaces.ts b/src/services/llm/tools/tool_interfaces.ts index 12c08a7b0..ec90df67f 100644 --- a/src/services/llm/tools/tool_interfaces.ts +++ b/src/services/llm/tools/tool_interfaces.ts @@ -2,6 +2,13 @@ * Tool Interfaces * * This file defines the interfaces for the LLM tool calling system. + * + * IMPORTANT NOTE ON NOTE IDs: + * When working with notes in Trilium, it's crucial to understand that: + * - Each note has a unique system ID (e.g., "abc123def456") which is different from its title + * - When tools require a noteId parameter, they need this system ID, not the title + * - Search tools return noteIds that should be used in subsequent operations on specific notes + * - Using a note's title instead of its ID will cause operations to fail */ /**