feat(llm): introduce request-local source reference aliases

Replace raw chunk/document/KB IDs in LLM context with short cN/dN/bN/wN
aliases, decode tool arguments on the way in, and expand compact <ref/>
citations to the public <kb>/<web> format before user-facing output.
This commit is contained in:
wizardchen
2026-07-16 21:23:20 +08:00
committed by lyingbug
parent 79e8f3d894
commit 014164ae44
33 changed files with 1962 additions and 149 deletions
@@ -16,13 +16,13 @@ var listKnowledgeChunksTool = BaseTool{
description: `Retrieve full chunk content for a document or a single FAQ entry.
## Use After grep_chunks or knowledge_search:
- **FAQ hit** (type faq): list_knowledge_chunks(faq_id="<chunk_id from search>") — reads that one FAQ entry with answers from metadata.
- **Document hit**: list_knowledge_chunks(knowledge_id="<document id>") — pages through all chunks.
- **FAQ hit** (type faq): list_knowledge_chunks(faq_id="cN") — reads that one FAQ chunk with answers from metadata.
- **Document hit**: list_knowledge_chunks(knowledge_id="dN") — pages through all chunks.
## Parameters (provide exactly one id target):
- faq_id (optional): FAQ entry ID from grep_chunks / knowledge_search.
- chunk_id (optional): Single non-FAQ chunk ID (do not use for FAQ — use faq_id).
- knowledge_id (optional): Document/knowledge ID to page through all chunks.
- faq_id (optional): Short cN ID for an FAQ chunk from grep_chunks / knowledge_search.
- chunk_id (optional): Short cN ID for a single non-FAQ chunk.
- knowledge_id (optional): Short dN document ID to page through all chunks.
- limit / offset: Only for knowledge_id paging (default limit 20, max 100).
## Output:
@@ -32,15 +32,15 @@ Full chunk content. FAQ entries include <faq> with <answer> from metadata.`,
"properties": {
"faq_id": {
"type": "string",
"description": "FAQ entry ID (same as chunk_id). Use for FAQ hits instead of knowledge_id."
"description": "Short cN FAQ chunk ID. Use for FAQ hits instead of the parent dN document ID."
},
"chunk_id": {
"type": "string",
"description": "Single chunk ID (alias of faq_id)"
"description": "Short cN ID for one non-FAQ chunk"
},
"knowledge_id": {
"type": "string",
"description": "Document/knowledge ID to list all chunks"
"description": "Short dN document ID to list all chunks"
},
"limit": {
"type": "integer",