Skip to content

Build your personal knowledge base with Trilium Notes

feat(llm): improve search discoverability

Elian Doran90930e19e7c2
diff --git a/apps/server/src/services/llm/providers/anthropic.ts b/apps/server/src/services/llm/providers/anthropic.ts
index 50298038c1..688ef9afa4 100644
--- a/apps/server/src/services/llm/providers/anthropic.ts
+++ b/apps/server/src/services/llm/providers/anthropic.ts
@@ -3,6 +3,7 @@ import { generateText, streamText, stepCountIs, type CoreMessage, type ToolSet }
import type { LlmMessage } from "@triliumnext/commons";
import becca from "../../../becca/becca.js";
+import { getSkillsSummary } from "../skills/index.js";
import { noteTools, attributeTools, hierarchyTools, skillTools, currentNoteTools } from "../tools/index.js";
import type { LlmProvider, LlmProviderConfig, ModelInfo, ModelPricing, StreamResult } from "../types.js";
@@ -135,6 +136,14 @@ export class AnthropicProvider implements LlmProvider {
}
}
+ // Add skills hint so the LLM knows to load skills before complex operations
+ if (config.enableNoteTools) {
+ const skillsHint = `You have access to skills that provide specialized instructions. Load a skill with the load_skill tool before performing complex operations.\n\nAvailable skills:\n${getSkillsSummary()}`;
+ systemPrompt = systemPrompt
+ ? `${systemPrompt}\n\n${skillsHint}`
+ : skillsHint;
+ }
+
// Convert to AI SDK message format with cache control breakpoints.
// The system prompt and conversation history (all but the last user message)
// are stable across turns, so we mark them for caching to reduce costs.
diff --git a/apps/server/src/services/llm/tools/note_tools.ts b/apps/server/src/services/llm/tools/note_tools.ts
index c3703b5a80..4e86b6aa1e 100644
--- a/apps/server/src/services/llm/tools/note_tools.ts
+++ b/apps/server/src/services/llm/tools/note_tools.ts
@@ -43,9 +43,19 @@ function setNoteContentFromLlm(note: { type: string; title: string; setContent:
* Search for notes in the knowledge base.
*/
export const searchNotes = tool({
- description: "Search for notes in the user's knowledge base using Trilium search syntax. Load the 'search_syntax' skill first if unsure about query format. Returns note metadata including title, type, and IDs.",
+ description: [
+ "Search for notes in the user's knowledge base using Trilium search syntax.",
+ "For complex queries (boolean logic, relations, regex, ordering), load the 'search_syntax' skill first via load_skill.",
+ "Common patterns:",
+ "- Full-text: 'rings tolkien' (notes containing both words)",
+ "- By label: '#book', '#status = done', '#year >= 2000'",
+ "- By type: 'note.type = code'",
+ "- By relation: '~author', '~author.title *= Tolkien'",
+ "- Combined: 'tolkien #book' (full-text + label filter)",
+ "- Negation: '#!archived' (notes WITHOUT label)"
+ ].join(" "),
inputSchema: z.object({
- query: z.string().describe("Search query in Trilium search syntax (e.g. '#book #year >= 2000', 'tolkien #fantasy')"),
+ query: z.string().describe("Search query in Trilium search syntax"),
fastSearch: z.boolean().optional().describe("If true, skip content search (only titles and attributes). Faster for large databases."),
includeArchivedNotes: z.boolean().optional().describe("If true, include archived notes in results."),
ancestorNoteId: z.string().optional().describe("Limit search to a subtree rooted at this note ID."),