An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Fix AI agent always creating dynamic anchor text block references https://github.com/siyuan-note/siyuan/issues/19311
Daniel4f8598df9696
diff --git a/kernel/agent/agent.go b/kernel/agent/agent.goindex 11a5cf5792..ad9782cb45 100644--- a/kernel/agent/agent.go+++ b/kernel/agent/agent.go@@ -91,7 +91,7 @@ second paragraph## Formatting- Inline formatting uses standard markdown: **bold**, *italic*, ~~strikethrough~~, ==mark==, and "code" (backticks).-- In markdown written to SiYuan blocks, block references must include anchor text. Use ((<blockID> "<static anchor text>")) for fixed text, or ((<blockID> '<dynamic anchor text>')) for text that follows the target block's content. Never use ((<blockID>)) or [[<blockID>]]. These forms are for note content; in chat responses use [title](siyuan://blocks/<blockID>).+- In markdown written to SiYuan blocks, block references must include anchor text. Use ((<blockID> "<static anchor text>")) for fixed text, which is required whenever the anchor text differs from the referenced block's content. Use ((<blockID> '<dynamic anchor text>')) for text that follows the target block's content, so only when the anchor text is the target block's own content. Never use ((<blockID>)) or [[<blockID>]]. These forms are for note content; in chat responses use [title](siyuan://blocks/<blockID>).- For text styling that markdown cannot express (color, background, font size), use SiYuan text marks.The syntax requires a leading data-type="text" attribute — WITHOUT it the HTML is escaped and shown as literal text:- Text color: <span data-type="text" style="color: #ff0000;">red text</span>diff --git a/kernel/agent/prompt_test.go b/kernel/agent/prompt_test.goindex 9028723328..3908c3ef81 100644--- a/kernel/agent/prompt_test.go+++ b/kernel/agent/prompt_test.go@@ -58,6 +58,10 @@ func TestSystemPromptDocumentsBlockReferenceSyntax(t *testing.T) {!strings.Contains(systemPrompt, `for text that follows the target block's content`) {t.Fatal("system prompt does not explain static and dynamic block-reference behavior")}+ if !strings.Contains(systemPrompt, `required whenever the anchor text differs from the referenced block's content`) ||+ !strings.Contains(systemPrompt, `only when the anchor text is the target block's own content`) {+ t.Fatal("system prompt does not tie static anchor text to mismatched content and dynamic anchor text to the target's own content")+ }if !strings.Contains(systemPrompt, `Never use ((<blockID>)) or [[<blockID>]]`) {t.Fatal("system prompt does not reject block references without anchor text or bracketed block IDs")}