Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(llm): reinforce not re-reading the file
Elian Doranbd84a3a3c19f
diff --git a/apps/server/src/services/llm/providers/base_provider.ts b/apps/server/src/services/llm/providers/base_provider.tsindex 9e17333233..e5cc6aec72 100644--- a/apps/server/src/services/llm/providers/base_provider.ts+++ b/apps/server/src/services/llm/providers/base_provider.ts@@ -99,6 +99,9 @@ export abstract class BaseProvider implements LlmProvider {parts.push(`Do not create, modify, or delete notes unless the user explicitly asks you to (e.g. "create a note", "save this to a note"). The chat supports rich Markdown rendering including code blocks, math equations, mermaid diagrams, and tables — so always present content directly in your response rather than creating a note for it. For example, if asked to "visualize an algorithm", render a mermaid diagram in the chat, don't create a note.`);+ parts.push(+ `After a successful write tool call (set_note_content, append_to_note, edit_note_content, create_note), the tool's result already contains the resulting content of the note. Do not call get_note_content to verify the write — trust the returned content.`+ );} else if (config.contextNoteId) {parts.push(`You can see the current note's metadata above, but you cannot search or access other notes. If the user asks about other notes, inform them that "Note access" is disabled and they need to enable it in the chat settings (click on the model name dropdown and toggle "Note access").`diff --git a/apps/server/src/services/llm/tools/note_tools.ts b/apps/server/src/services/llm/tools/note_tools.tsindex 568b55e91d..0e68d4b9c6 100644--- a/apps/server/src/services/llm/tools/note_tools.ts+++ b/apps/server/src/services/llm/tools/note_tools.ts@@ -98,7 +98,7 @@ export const noteTools = defineTools({},set_note_content: {- description: "Replace the ENTIRE content of a note. Only use this for a full rewrite or for rich-text ('text') notes. For small or localized changes to a non-text note, prefer edit_note_content — resending the whole note wastes tokens. For text notes, provide Markdown content.",+ description: "Replace the ENTIRE content of a note. Only use this for a full rewrite or for rich-text ('text') notes. For small or localized changes to a non-text note, prefer edit_note_content — resending the whole note wastes tokens. For text notes, provide Markdown content. Returns the resulting content; do not call get_note_content afterwards to verify.",inputSchema: z.object({noteId: z.string().describe("The ID of the note to update"),content: z.string().describe("The new content for the note (Markdown for text notes, plain text for code notes)")@@ -128,7 +128,7 @@ export const noteTools = defineTools({},append_to_note: {- description: "Append content to the end of an existing note. For text notes, provide Markdown content.",+ description: "Append content to the end of an existing note. For text notes, provide Markdown content. Returns the resulting (combined) content; do not call get_note_content afterwards to verify.",inputSchema: z.object({noteId: z.string().describe("The ID of the note to append to"),content: z.string().describe("The content to append (Markdown for text notes, plain text for code notes)")@@ -177,7 +177,9 @@ export const noteTools = defineTools({"changes to large notes — it is far cheaper. Each edit's oldText must appear","exactly once in the note; include surrounding context to make it unique.","Multiple edits are applied in order. Does not support rich-text ('text')",- "notes — use set_note_content for those."+ "notes — use set_note_content for those.",+ "Returns the resulting content with all edits applied; do not call",+ "get_note_content afterwards to verify."].join(" "),inputSchema: z.object({noteId: z.string().describe("The ID of the note to edit"),@@ -230,7 +232,7 @@ export const noteTools = defineTools({create_note: {description: [- "Create a new note in the user's knowledge base. Returns the created note's ID and title.",+ "Create a new note in the user's knowledge base. Returns the created note's ID, title, and stored content — do not call get_note_content afterwards to verify.","Note types:","- 'text': rich text (provide content in Markdown)","- 'code': source code (must also set mime)",