WeKnora/frontend/src/stores
lyingbug 2be7bd4063
fix(agent): search bound knowledge bases before answering, and pass suggested-question origins (#3400)
* fix(agent): search bound knowledge bases before answering, and pass suggested-question origins

A user picked the suggested question "为什么在比较图形时需要谨慎处理?"
and the agent answered in round 1 with no tool call, claiming it had
searched the knowledge base and found nothing, then explained misleading
statistical charts. The question had been generated from "Corners Don't
Look Like That: Regarding Screenspace Ambient Occlusion" in a bound base,
where "comparing graphs" means SSAO falloff curves.

Two things let that happen: the grounding prompt said "Stable general
explanations need no lookup", and nothing told the agent where the
question came from - the base in question had no profile, only two
recent titles in the directory, and the click sent the text alone.

Prompt
- With knowledge tools available, search bound bases before answering a
  question about a topic, even one that reads like general knowledge;
  directory profiles and recent titles cannot prove a base lacks it.
- The general-explanation exemption applies only without bound bases.
- Say you searched or found nothing only when a search tool ran.

Question origin
- Suggested questions from FAQ/document chunks also return knowledge_id.
- Picking one on the home or chat page sends question_origin
  {knowledge_base_id, knowledge_id} with that question only.
- The service keeps the origin only when its base is inside the turn's
  resolved scope and the document belongs to that base; it never
  changes the scope (unlike knowledge_base_ids, which narrows it).
- The engine renders it in runtime_context as <question_origin> with the
  base and document handles and a note to search it before answering.

* fix(agent): keep question origins across file/tag scopes and bind them to the send

Review follow-up for the suggested-question origin.

- Scope check: the origin was kept only when its base was in the resolved
  KB list, which is empty for file-only and tag-only scopes even though
  their bases are searched. It is now checked against SearchTargets after
  they are built; the document is kept only when a target for that base
  covers it (unfiltered base, or a document scope listing it).
  resolveQuestionOriginInfo re-checks SearchTargets, looks up the name of
  a base that is not in kbInfos, and the renderer omits an unknown name.
- Frontend: the origin travelled through module-level "pending" state, so
  a send that returned early (agent not ready, upload in progress,
  steering) left it behind and a second pick overwrote it. It now rides
  with the one send: triggerSend(text, options) -> createSession ->
  send-msg -> sendMsg / changeFirstQuery.
- RetrieveKBOnlyWhenMentioned: suggestions are still generated from the
  agent's bases, but picking one retrieved nothing. The origin now
  selects its base, as an @mention would, when the agent may read it.
- API sync: question_origin in docs/api/chat.md and swagger;
  QuestionOrigin on the Go SDK's KnowledgeQARequest/AgentQARequest and
  knowledge_id on SuggestedQuestion.
2026-09-18 17:00:47 +08:00
..
auth.ts fix(invitation): harden auto-accept follow-ups from code review 2026-08-10 15:47:29 +08:00
browserConnection.test.ts feat(browser): polish connection settings, open tasks in a new window, and streamline prompts (#3193) 2026-09-11 21:28:58 +08:00
browserConnection.ts feat(browser): polish connection settings, open tasks in a new window, and streamline prompts (#3193) 2026-09-11 21:28:58 +08:00
browserSource.test.ts feat(browser): connect local Chrome with task controls and display modes (#3180) 2026-09-11 17:59:27 +08:00
chatResources.ts feat(agent): keep long sandbox turns from truncating, overflowing, or rewriting files 2026-09-02 22:09:09 +08:00
commandPalette.ts fix(security): namespace command-palette recent searches per (user, tenant) 2026-05-18 17:28:58 +08:00
deploymentCapabilities.ts fix: filter menus by deployment capabilities (#2674) 2026-08-13 20:18:48 +08:00
editorResources.ts fix(frontend): keep agent editor dependency loading alive for contributors 2026-09-08 12:28:44 +08:00
knowledge.ts feat(ui): Support multi knowledgebases operation 2025-09-17 16:02:08 +08:00
localizedResourceCache.test.ts fix(i18n): 修复内置智能体名称与描述不随界面语言切换的问题 (#2828) 2026-08-27 11:53:45 +08:00
localizedResourceCache.ts fix(i18n): 修复内置智能体名称与描述不随界面语言切换的问题 (#2828) 2026-08-27 11:53:45 +08:00
menu.ts fix(agent): search bound knowledge bases before answering, and pass suggested-question origins (#3400) 2026-09-18 17:00:47 +08:00
organization.ts fix(i18n): 修复内置智能体名称与描述不随界面语言切换的问题 (#2828) 2026-08-27 11:53:45 +08:00
organizationState.test.ts fix(frontend): correct optimistic organization state after review and detail loads 2026-07-24 10:45:12 +08:00
organizationState.ts fix(frontend): correct optimistic organization state after review and detail loads 2026-07-24 10:45:12 +08:00
sessionActivity.ts feat(session): show in-progress status in the sidebar 2026-09-05 23:32:13 +08:00
sessionActivityState.test.ts feat(session): show in-progress status in the sidebar 2026-09-05 23:32:13 +08:00
sessionActivityState.ts feat(session): show in-progress status in the sidebar 2026-09-05 23:32:13 +08:00
settings.ts feat(browser): polish connection settings, open tasks in a new window, and streamline prompts (#3193) 2026-09-11 21:28:58 +08:00
settingsStorage.test.mjs fix(frontend): harden settings localStorage load after #1925 2026-07-06 10:46:34 +08:00
settingsStorage.ts refactor: remove Neo4j-based conversation memory feature 2026-07-18 23:41:48 +08:00
storageEngineAccess.test.ts fix(frontend): keep agent editor dependency loading alive for contributors 2026-09-08 12:28:44 +08:00
storageEngineAccess.ts fix(frontend): keep agent editor dependency loading alive for contributors 2026-09-08 12:28:44 +08:00
ui.ts feat(frontend): unify document tag filter, manage drawer, and detail UX 2026-06-26 12:26:29 +08:00
uploadConfirm.ts feat(knowledge): enhance folder management and upload confirmation dialog 2026-08-04 20:45:29 +08:00
uploadQueue.test.ts feat(frontend): show overall progress for knowledge file uploads (#3399) 2026-09-18 16:43:59 +08:00
uploadQueue.ts feat(frontend): show overall progress for knowledge file uploads (#3399) 2026-09-18 16:43:59 +08:00
uploadTasks.ts feat(frontend): show overall progress for knowledge file uploads (#3399) 2026-09-18 16:43:59 +08:00
uploadTasksCore.test.ts feat(frontend): show overall progress for knowledge file uploads (#3399) 2026-09-18 16:43:59 +08:00
uploadTasksCore.ts feat(frontend): show overall progress for knowledge file uploads (#3399) 2026-09-18 16:43:59 +08:00
uploadTasksState.test.ts feat(frontend): show overall progress for knowledge file uploads (#3399) 2026-09-18 16:43:59 +08:00
uploadTasksState.ts feat(frontend): show overall progress for knowledge file uploads (#3399) 2026-09-18 16:43:59 +08:00
versionedRequest.test.ts fix: synchronize organization state after writes 2026-07-24 10:40:33 +08:00
versionedRequest.ts fix: synchronize organization state after writes 2026-07-24 10:40:33 +08:00