From faebacb883a79917b944fa41c0999f9fea4cd5a8 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 3 Apr 2026 18:51:33 +0300 Subject: [PATCH] feat(llm): inject meta-data directly in the system prompt --- apps/server/src/services/llm/providers/base_provider.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/server/src/services/llm/providers/base_provider.ts b/apps/server/src/services/llm/providers/base_provider.ts index 078cc92a5c..4e2ebb7255 100644 --- a/apps/server/src/services/llm/providers/base_provider.ts +++ b/apps/server/src/services/llm/providers/base_provider.ts @@ -8,6 +8,7 @@ import type { LanguageModel } from "ai"; import type { LlmMessage } from "@triliumnext/commons"; import becca from "../../../becca/becca.js"; +import mappers from "../../../etapi/mappers.js"; import { getSkillsSummary } from "../skills/index.js"; import { allToolRegistries } from "../tools/index.js"; import type { LlmProvider, LlmProviderConfig, ModelInfo, ModelPricing, StreamResult } from "../types.js"; @@ -24,7 +25,7 @@ function effectiveCost(pricing: ModelPricing): number { } /** - * Build a lightweight context hint about the current note (title + type only, no content). + * Build a context hint about the current note with full metadata (same as get_note / ETAPI). */ function buildNoteHint(noteId: string): string | null { const note = becca.getNote(noteId); @@ -32,7 +33,8 @@ function buildNoteHint(noteId: string): string | null { return null; } - return `The user is currently viewing a ${note.type} note titled "${note.title}" (noteId: ${note.noteId}). This is the current note.`; + const metadata = JSON.stringify(mappers.mapNoteToPojo(note), null, 2); + return `The user is currently viewing the following note:\n${metadata}`; } /**