Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

fix(agent): route new knowledge through document ingestion (#4525)

lyingbug20597163de35
diff --git a/config/prompt_templates/agent_system_prompt.yaml b/config/prompt_templates/agent_system_prompt.yaml
index 85c3b1d52..9a328d73a 100644
--- a/config/prompt_templates/agent_system_prompt.yaml
+++ b/config/prompt_templates/agent_system_prompt.yaml
@@ -124,7 +124,7 @@ templates:
1. If issue IDs were supplied, read them with wiki_read_issue. Read the current target page; independent issue and page reads can run together. For a directly described problem, use that description without inventing an issue ID.
2. Check whether the issue still exists. If it is already fixed, avoid redundant page edits and update the provided issue status when appropriate.
3. Verify factual corrections against the original source documents. Do not treat either an issue description or the current generated Wiki page as unquestionable truth.
- 4. Choose the smallest supported repair. Preserve valid content, source references, images, and Wiki links. Before creating a page, search for an existing canonical page to avoid duplicates.
+ 4. Choose the smallest supported repair. Preserve valid content, source references, images, and Wiki links.
5. Apply the requested repair with available tools. A repair request authorizes the needed edits, but does not authorize unrelated deletion or changes to other subjects. Follow any narrower scope or read-only request from the user.
6. For replacement, use exact current old_text. For a full write, provide complete content, title, summary, page_type, and source_refs as required by the tool definition; do not use omitted-content placeholders.
7. Inspect write results and verify the affected content. Mark supplied issues resolved only when the repair succeeded or the issue was already resolved; explain unresolved parts accurately.
@@ -181,6 +181,7 @@ templates:
- knowledge_base.update changes the settings you send. A field left out is kept, including one indexing flag or one chunk size. embedding_model_id cannot change after the knowledge base has documents. vector_store_id cannot be changed. Graph node and relation types stay in the knowledge base editor.
- Tags belong to a knowledge base. Create or rename them there, then set them on documents with knowledge.set_tags. Deleting a tag fails while documents still use it; take it off those documents first. Do not delete documents to remove a tag.
- knowledge.update_manual replaces the whole Markdown of a document that was created as manual knowledge. Send the complete text. Uploaded files are not edited this way.
+ - Save new content through knowledge.create_manual (text) or knowledge.create_from_url (a user-provided URL), even when the destination is called a Wiki. Ingestion builds the configured indexes and generates Wiki pages when enabled; Wiki tools maintain those derived pages.
Checking that a setup works:
- Verify what you set up instead of leaving it to the user. After binding an MCP service to an agent, or when the user says one does not work, run mcp_service.test, then mcp_service.list_tools to confirm it offers the tools the agent needs.
- When the user asks why something is not found, run knowledge_base.search with their wording: first without thresholds, then with the agent's vector_threshold and keyword_threshold. Say whether the document is missing, still parsing, or found but cut by a threshold or ranked too low, and propose the change that would fix it.
@@ -204,7 +205,7 @@ templates:
1. If issues are listed in page_context or named by the user, read them with wiki_read_issue together with their page. For a problem the user describes directly, work from that description without inventing an issue.
2. Check whether the issue still exists. If it is already fixed, do not edit the page; update the issue status when appropriate.
3. Verify factual corrections against the original documents. Neither an issue description nor the current generated page is unquestionable.
- 4. Make the smallest supported repair. Preserve valid content, source references, images and [[slug|display name]] links. Search for an existing canonical page before creating one.
+ 4. Make the smallest supported repair. Preserve valid content, source references, images and [[slug|display name]] links.
5. For replacement, use the exact current old_text. For a full write, provide complete content, title, summary, page_type and source_refs; never use omitted-content placeholders.
6. Check the write result. Mark an issue resolved only when the repair succeeded or it was already resolved.
Reporting:
diff --git a/docs/docs.go b/docs/docs.go
index 96116fffa..31227d083 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -8252,7 +8252,7 @@ const docTemplate = `{
"risk": "write",
"target": "knowledge_base.get"
},
- "x-agent-hint": "Creates a Markdown document. Send the full content, and status draft to keep it out of search or publish to index it."
+ "x-agent-hint": "Creates a source document from complete Markdown. Set status publish to start asynchronous ingestion; omitted status defaults to draft without indexing. Use draft only when requested. Check knowledge.get_parse_progress."
}
},
"/knowledge-bases/{id}/knowledge/url": {
@@ -8334,7 +8334,7 @@ const docTemplate = `{
"risk": "write",
"target": "knowledge_base.get"
},
- "x-agent-hint": "Fetches a public web page or file into the knowledge base and parses it in the background; follow with knowledge.get_parse_progress. Only use a URL the user gave."
+ "x-agent-hint": "Imports a user-provided public web page or file URL as a source document; ingests asynchronously. Check knowledge.get_parse_progress."
}
},
"/knowledge-bases/{id}/move-targets": {
diff --git a/docs/swagger.json b/docs/swagger.json
index f2a7f456a..b27711243 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -8245,7 +8245,7 @@
"risk": "write",
"target": "knowledge_base.get"
},
- "x-agent-hint": "Creates a Markdown document. Send the full content, and status draft to keep it out of search or publish to index it."
+ "x-agent-hint": "Creates a source document from complete Markdown. Set status publish to start asynchronous ingestion; omitted status defaults to draft without indexing. Use draft only when requested. Check knowledge.get_parse_progress."
}
},
"/knowledge-bases/{id}/knowledge/url": {
@@ -8327,7 +8327,7 @@
"risk": "write",
"target": "knowledge_base.get"
},
- "x-agent-hint": "Fetches a public web page or file into the knowledge base and parses it in the background; follow with knowledge.get_parse_progress. Only use a URL the user gave."
+ "x-agent-hint": "Imports a user-provided public web page or file URL as a source document; ingests asynchronously. Check knowledge.get_parse_progress."
}
},
"/knowledge-bases/{id}/move-targets": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 41cd2706c..06f70a21f 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -19575,8 +19575,9 @@ paths:
label: name
risk: write
target: knowledge_base.get
- x-agent-hint: Creates a Markdown document. Send the full content, and status
- draft to keep it out of search or publish to index it.
+ x-agent-hint: Creates a source document from complete Markdown. Set status publish
+ to start asynchronous ingestion; omitted status defaults to draft without
+ indexing. Use draft only when requested. Check knowledge.get_parse_progress.
/knowledge-bases/{id}/knowledge/url:
post:
consumes:
@@ -19627,9 +19628,8 @@ paths:
label: name
risk: write
target: knowledge_base.get
- x-agent-hint: Fetches a public web page or file into the knowledge base and
- parses it in the background; follow with knowledge.get_parse_progress. Only
- use a URL the user gave.
+ x-agent-hint: Imports a user-provided public web page or file URL as a source
+ document; ingests asynchronously. Check knowledge.get_parse_progress.
/knowledge-bases/{id}/move-targets:
get:
description: 返回与源知识库 Type 一致、EmbeddingModelID 一致、非临时且不是自身的目标知识库列表
diff --git a/internal/agent/tools/wiki_write_page.go b/internal/agent/tools/wiki_write_page.go
index 7331ed6cc..8c339c19d 100644
--- a/internal/agent/tools/wiki_write_page.go
+++ b/internal/agent/tools/wiki_write_page.go
@@ -31,7 +31,9 @@ func NewWikiWritePageTool(
return &wikiWritePageTool{
BaseTool: NewBaseTool(
ToolWikiWritePage,
- "Create a new Wiki page or completely overwrite an existing one. Automatically handles outbound links.",
+ "Revise or consolidate a Wiki page after reading it. Creation is for missing derived pages "+
+ "from already ingested sources; search first. Maintains Wiki links, "+
+ "but does not ingest documents or create document chunks/indexes.",
json.RawMessage(`{
"type": "object",
"properties": {
@@ -158,9 +160,8 @@ func (t *wikiWritePageTool) Execute(ctx context.Context, args json.RawMessage) (
(isSummaryNamespace(params.Slug) || strings.EqualFold(params.PageType, types.WikiPageTypeSummary)) {
return &types.ToolResult{
Success: false,
- Error: "summary pages are generated automatically from source documents and cannot be created manually. " +
- "Use page_type 'synthesis'/'comparison'/'entity'/'concept' for authored pages, " +
- "or target an existing summary page to update it.",
+ Error: "summary pages are generated by document ingestion. " +
+ "To edit one, target an existing summary page.",
}, nil
}
diff --git a/internal/handler/knowledge.go b/internal/handler/knowledge.go
index 44202fe3c..ed68f64ea 100644
--- a/internal/handler/knowledge.go
+++ b/internal/handler/knowledge.go
@@ -488,7 +488,7 @@ type CreateKnowledgeFromURLRequest struct {
// @Security Bearer
// @Security ApiKeyAuth
// @x-agent {"id":"knowledge.create_from_url","risk":"write","target":"knowledge_base.get","label":"name"}
-// @x-agent-hint "Fetches a public web page or file into the knowledge base and parses it in the background; follow with knowledge.get_parse_progress. Only use a URL the user gave."
+// @x-agent-hint "Imports a user-provided public web page or file URL as a source document; ingests asynchronously. Check knowledge.get_parse_progress."
// @Router /knowledge-bases/{id}/knowledge/url [post]
func (h *KnowledgeHandler) CreateKnowledgeFromURL(c *gin.Context) {
ctx := c.Request.Context()
@@ -578,7 +578,7 @@ func (h *KnowledgeHandler) CreateKnowledgeFromURL(c *gin.Context) {
// @Security Bearer
// @Security ApiKeyAuth
// @x-agent {"id":"knowledge.create_manual","risk":"write","target":"knowledge_base.get","label":"name"}
-// @x-agent-hint "Creates a Markdown document. Send the full content, and status draft to keep it out of search or publish to index it."
+// @x-agent-hint "Creates a source document from complete Markdown. Set status publish to start asynchronous ingestion; omitted status defaults to draft without indexing. Use draft only when requested. Check knowledge.get_parse_progress."
// @Router /knowledge-bases/{id}/knowledge/manual [post]
func (h *KnowledgeHandler) CreateManualKnowledge(c *gin.Context) {
ctx := c.Request.Context()
diff --git a/website-docs/03-features/14-wiki.md b/website-docs/03-features/14-wiki.md
index 209e5ca7a..4b5665894 100644
--- a/website-docs/03-features/14-wiki.md
+++ b/website-docs/03-features/14-wiki.md
@@ -18,6 +18,22 @@ Wiki 将知识库资料整理为相互链接的 Markdown 页面。文档入库
Wiki 生成会增加模型调用,用量取决于文档规模和抽取密度。可在知识库 Wiki 配置中选择 `focused`、`standard` 或 `exhaustive`,详细说明见[抽取粒度](#抽取粒度)。
+## 新增资料入库与修订 Wiki 页面 {#ingest-or-edit}
+
+需要长期保存的新报告、笔记、研究总结或网页,应先作为源文档加入知识库。文档处理管道负责分块、建立已启用的检索索引;知识库开启 Wiki 索引时,还会生成或更新带来源引用的 Wiki 页面及页面间链接。
+
+使用助手时,按内容选择入口:
+
+| 任务 | 入口 |
+| --- | --- |
+| 保存新的文本或 Markdown 内容 | `knowledge.create_manual`,传入完整正文和 `status: publish` |
+| 导入用户提供的网页或文件 URL | `knowledge.create_from_url` |
+| 修订、合并已存在的 Wiki 页面 | 先读取页面,再使用 `wiki_write_page` 整页更新或 `wiki_replace_text` 局部替换 |
+
+手工文档省略 `status` 时默认为 `draft`,只保存草稿,不启动索引。发布和 URL 导入都是异步处理,通过 `knowledge.get_parse_progress` 查看进度。
+
+直接写 Wiki 页面仍可维护链接、出现在 Wiki 图谱中并被 Wiki 搜索命中;但不会创建源文档、分块或文档检索索引,不能替代入库。
+
## 浏览 Wiki 图谱 {#wiki-graph}
<Screenshot
@@ -191,7 +207,7 @@ migration `000061_wiki_page_hierarchy.up.sql` 引入独立的 `wiki_folders` 表
| --- | --- | --- |
| `wiki_read_page` | 按 slug 批量读取页面全文 | `slugs: string[]` |
| `wiki_search` | 搜索页面(标题 / slug / 别名 / 摘要 / 内容;`query` 按大小写不敏感的 POSIX 正则解释,不是合法正则的文本如 `C++` 按字面匹配;`regex=false` 强制字面匹配) | `query`、`regex?`、`knowledge_base_ids?`、`limit?`(旧参数 `queries`、`knowledge_base_id` 仍接受) |
-| `wiki_write_page` | 创建/整页覆盖(`synthesis`、`comparison` 页只能由此创建) | `slug`、`title`、`summary`、`content`、`page_type`、`aliases?`、`source_refs?` |
+| `wiki_write_page` | 整页修订或合并已有页面;也支持从已入库来源重建缺失衍生页,不执行文档入库 | `slug`、`title`、`summary`、`content`、`page_type`、`aliases?`、`source_refs?` |
| `wiki_replace_text` | 页内精确文本替换 | `slug`、`old_text`、`new_text` |
| `wiki_rename_page` | 重命名 slug,自动更新反向链接 | `slug`、`new_slug` |
| `wiki_delete_page` | 删除页面并清理死链 | `slug` |