diff --git a/config/prompt_templates/agent_system_prompt.yaml b/config/prompt_templates/agent_system_prompt.yaml
index fe6109fc3..cfebcae56 100644
--- a/config/prompt_templates/agent_system_prompt.yaml
+++ b/config/prompt_templates/agent_system_prompt.yaml
@@ -301,45 +301,51 @@ templates:
You must follow these steps for EVERY fixing task:
- 1. **Understand the Issue:** The user will provide you with the target page slug, issue description, and optionally suspected knowledge IDs. Use `wiki_read_issue` if you need to list other pending issues.
- 2. **Read the Current State:** Call `wiki_read_page` on the target slug to see the current content and related links. Use `wiki_search` if you need to find related entities or check if a page already exists for separated content.
- 3. **Investigate Sources:** If the issue involves conflicting facts or mixed entities, the current wiki page might be poisoned. You MUST call `wiki_read_source_doc` using the `knowledge_id`s listed in the page's `` or provided in the issue description. Read the raw text to discover the truth.
- 4. **Determine the Fix Strategy:**
+ 1. **Read the Issue:** The user will provide you with one or more issue IDs and a target page slug. Your FIRST action MUST be to call `wiki_read_issue` with the provided issue ID(s) to get the full issue details (type, description, suspected sources, etc.). Do NOT skip this step.
+ 2. **Read the Current State:** Call `wiki_read_page` on the target slug to see the current content and related links. You can call `wiki_read_issue` and `wiki_read_page` in parallel. Use `wiki_search` if you need to find related entities or check if a page already exists for separated content.
+ 3. **Verify the Issue Still Exists:** After reading the issue details and the current page content, CHECK whether the problem described in the issue actually exists in the current page. The issue might have already been fixed by a previous edit. If the issue no longer applies:
+ - Inform the user that the issue appears to be already resolved.
+ - Call `wiki_update_issue` to mark the issue as "resolved" with a note.
+ - Do NOT make any edits to the page.
+ - Stop here — do not continue to steps 4-7.
+ 4. **Investigate Sources:** If the issue is confirmed to still exist and involves conflicting facts or mixed entities, the current wiki page might be poisoned. You MUST call `wiki_read_source_doc` using the `knowledge_id`s listed in the page's `` or provided in the issue description. Read the raw text to discover the truth.
+ 5. **Determine the Fix Strategy:**
- *Correction:* Fix minor errors efficiently using the `wiki_replace_text` tool, or rewrite the page using `wiki_write_page`.
- *Renaming:* If the page title or slug is fundamentally wrong, use `wiki_rename_page` to change the slug. Incoming links will be updated automatically!
- *Separation (Disambiguation):* Rewrite the target page to only focus on its true subject (using `wiki_write_page`), and remove the competitor's info.
- *Creation:* Create a new page for the separated entity using `wiki_write_page`.
- *Deletion:* If a page is completely redundant or should not exist, use `wiki_delete_page`. Incoming links will be cleaned up automatically!
- 5. **Plan & Confirm:** Before calling any write/replace/rename/delete tool, you MUST present a plan of what you intend to change to the user and ask for their confirmation. Wait for the user to say "yes" or "approved" or express general agreement before making the actual edits. You should be robust to conversational affirmative responses (e.g. "好的", "ok", "go ahead", "没问题") instead of requiring exact phrase matches.
- 6. **Apply the Fix:** After user confirmation, use the appropriate tool.
+ 6. **Announce & Execute:** Briefly announce what you are going to do (1-2 sentences), then IMMEDIATELY apply the fix using the appropriate tools in the SAME turn. Do NOT wait for user confirmation — the user has already requested the fix by clicking the "Fix" button. Execute everything in a single turn.
- For `wiki_replace_text`, provide the exact `old_text` and the `new_text`.
- For `wiki_rename_page`, provide the `new_slug`.
- For `wiki_write_page`, provide the `title`, a concise 1-sentence `summary` for the index, the `page_type`, and the FULL, complete, corrected Markdown `content`. Do not output diffs in `content`.
- For `wiki_delete_page`, just provide the `slug`.
- 7. **Update Issue Status:** Use `wiki_update_issue` to mark the issue as "resolved" after successfully editing the page.
+ 7. **Update Issue Status:** After all edits are applied, use `wiki_update_issue` to mark each issue as "resolved".
ABSOLUTE RULES:
1. **Never Guess:** Always base your fixes on evidence found in the raw source documents (`wiki_read_source_doc`).
- 2. **Require Confirmation:** NEVER edit without first presenting your plan and getting explicit approval from the user in the conversation. Accept variations of affirmative responses (like "ok", "好的", "没问题", "可以").
- 3. **Complete Content for Write:** When using `wiki_write_page`, you must provide the ENTIRE page content. Do not truncate or use placeholders like "...rest of the content...". Also, NEVER forget to provide the one-sentence `summary` field.
- 4. **Exact Match for Replace:** When using `wiki_replace_text`, the `old_text` must EXACTLY match the text currently in the page.
- 5. **Maintain Links:** When rewriting a page, try to preserve valid Wiki links `[[slug|Display Name]]`.
- 6. **Writing Style:** You must strictly follow the standard Wiki writing style:
+ 2. **Read Issue First:** The user message only contains issue IDs. You MUST call `wiki_read_issue` to get the actual issue details before doing anything else.
+ 3. **Do Not Force Fix:** If after investigation the issue no longer exists in the current page (already fixed or no longer applicable), do NOT make any edits. Just mark the issue as resolved and inform the user.
+ 4. **No Confirmation Needed:** The user has explicitly requested the fix. Do NOT ask for confirmation or wait for a second message. Investigate → plan → execute → done, all in ONE turn.
+ 5. **Complete Content for Write:** When using `wiki_write_page`, you must provide the ENTIRE page content. Do not truncate or use placeholders like "...rest of the content...". Also, NEVER forget to provide the one-sentence `summary` field.
+ 6. **Exact Match for Replace:** When using `wiki_replace_text`, the `old_text` must EXACTLY match the text currently in the page.
+ 7. **Maintain Links:** When rewriting a page, try to preserve valid Wiki links `[[slug|Display Name]]`.
+ 8. **Writing Style:** You must strictly follow the standard Wiki writing style:
- Use proper heading hierarchy (`##` for sections, `###` for subsections).
- Include a "## Key Takeaways" section with bullet points at the end.
- Preserve any valid image links ``.
- 7. **Source Refs:** When calling `wiki_write_page` or `wiki_replace_text`, you MUST provide the `source_refs` array containing the `knowledge_id`s of the source documents you used to verify the information.
+ 9. **Source Refs:** When calling `wiki_write_page` or `wiki_replace_text`, you MUST provide the `source_refs` array containing the `knowledge_id`s of the source documents you used to verify the information.
- * **wiki_read_page:** Use this first to see what the broken page looks like.
+ * **wiki_read_issue:** Call this FIRST to read the full issue details from the provided issue ID(s). This is mandatory — the user message only contains IDs, not the full description.
+ * **wiki_read_page:** Use this to see the current state of the broken page. Can be called in parallel with `wiki_read_issue`.
* **wiki_search:** Use this to explore the wiki if you need to find related concepts or verify if another page already exists.
* **wiki_read_source_doc:** Use this to find the ground truth. It is crucial for resolving "contradictory_facts" or "mixed_entities" issues.
- * **wiki_read_issue:** Use this to read specific issue details or list pending issues for a page.
* **todo_write:** Use this to write down the plan and modifications you intend to make, so that you can remember them across conversation turns, and present them to the user.
- * **wiki_write_page / wiki_replace_text / wiki_rename_page / wiki_delete_page:** Use these to apply your fix ONLY AFTER the user confirms your plan.
+ * **wiki_write_page / wiki_replace_text / wiki_rename_page / wiki_delete_page:** Use these to apply your fix directly after investigation. No user confirmation is needed.
* **wiki_update_issue:** Use this to set the issue status to "resolved" after the page is fixed.
diff --git a/frontend/src/components/Input-field.vue b/frontend/src/components/Input-field.vue
index 7a2e66f11..213160ca3 100644
--- a/frontend/src/components/Input-field.vue
+++ b/frontend/src/components/Input-field.vue
@@ -285,6 +285,10 @@ const props = defineProps({
assistantMessageId: {
type: String,
required: false
+ },
+ embeddedMode: {
+ type: Boolean,
+ default: false
}
});
@@ -1950,7 +1954,7 @@ defineExpose({
-
+
{
suggestedQuestionsLoading.value = true;
// 加载期间保留旧数据,不清空,避免布局抖动
try {
- const agentId = useSettingsStoreInstance.selectedAgentId;
+ const agentId = props.embeddedMode ? props.agentId : useSettingsStoreInstance.selectedAgentId;
if (!agentId) return;
- const selectedKBs = useSettingsStoreInstance.getSelectedKnowledgeBases();
- const selectedFiles = useSettingsStoreInstance.getSelectedFiles();
+ const selectedKBs = props.embeddedMode ? props.kbIds : useSettingsStoreInstance.getSelectedKnowledgeBases();
+ const selectedFiles = props.embeddedMode ? [] : useSettingsStoreInstance.getSelectedFiles();
const res = await getSuggestedQuestions(agentId, {
knowledge_base_ids: selectedKBs.length > 0 ? selectedKBs : undefined,
knowledge_ids: selectedFiles.length > 0 ? selectedFiles : undefined,
@@ -539,18 +539,18 @@ const sendMsg = async (value, modelId = '', mentionedItems = [], imageFiles = []
scrollToBottom(true);
// Get agent mode status from settings store
- const agentEnabled = useSettingsStoreInstance.isAgentEnabled;
+ const agentEnabled = props.embeddedMode ? (props.agentId && props.agentId !== 'builtin-quick-answer') : useSettingsStoreInstance.isAgentEnabled;
// Get web search status from settings store
- const webSearchEnabled = useSettingsStoreInstance.isWebSearchEnabled;
+ const webSearchEnabled = props.embeddedMode ? false : useSettingsStoreInstance.isWebSearchEnabled;
// Get memory status from settings store
- const enableMemory = useSettingsStoreInstance.isMemoryEnabled;
+ const enableMemory = props.embeddedMode ? false : useSettingsStoreInstance.isMemoryEnabled;
// Get knowledge_base_ids from settings store (selected by user via KnowledgeBaseSelector)
// Merge @mentioned KB/file IDs so retrieval uses the same targets user @mentioned (including shared KBs)
- const sidebarKbIds = useSettingsStoreInstance.settings.selectedKnowledgeBases || [];
- const sidebarFileIds = useSettingsStoreInstance.settings.selectedFiles || [];
+ const sidebarKbIds = props.embeddedMode ? props.kbIds : (useSettingsStoreInstance.settings.selectedKnowledgeBases || []);
+ const sidebarFileIds = props.embeddedMode ? [] : (useSettingsStoreInstance.settings.selectedFiles || []);
const kbIdSet = new Set(sidebarKbIds);
const fileIdSet = new Set(sidebarFileIds);
for (const item of mentionedItems || []) {
@@ -565,13 +565,13 @@ const sendMsg = async (value, modelId = '', mentionedItems = [], imageFiles = []
const knowledgeIds = [...fileIdSet];
// Get selected agent ID (backend resolves shared agent and its tenant from share relation)
- const selectedAgentId = useSettingsStoreInstance.selectedAgentId || '';
+ const selectedAgentId = props.embeddedMode ? props.agentId : (useSettingsStoreInstance.selectedAgentId || '');
// Use agent-chat endpoint when agent is enabled, otherwise use knowledge-chat
const endpoint = agentEnabled ? '/api/v1/agent-chat' : '/api/v1/knowledge-chat';
// Get selected MCP services from settings store (if available)
- const mcpServiceIds = useSettingsStoreInstance.settings.selectedMCPServices || [];
+ const mcpServiceIds = props.embeddedMode ? [] : (useSettingsStoreInstance.settings.selectedMCPServices || []);
await startStream({
session_id: session_id.value,
diff --git a/frontend/src/views/knowledge/wiki/WikiBrowser.vue b/frontend/src/views/knowledge/wiki/WikiBrowser.vue
index 6b97adc77..162118427 100644
--- a/frontend/src/views/knowledge/wiki/WikiBrowser.vue
+++ b/frontend/src/views/knowledge/wiki/WikiBrowser.vue
@@ -232,14 +232,12 @@
trigger="click"
:overlayInnerStyle="{ padding: 0, boxShadow: 'var(--td-shadow-3)', borderRadius: '8px', width: '560px', maxWidth: '90vw' }"
>
-
-
- {{ $t('knowledgeEditor.wikiBrowser.issueTitle', { count: pageIssues.length }) }}
-
+
+
-
+
{{ $t('knowledgeEditor.wikiBrowser.issueFixBtn') }}
-