feat(agent): enforce model readiness and polish selector UX

Block chat when agents lack an explicit chat or rerank model, guide users
through the selector and editor with field highlight, and align session QA
checks with the same readiness rules on backend and frontend.
This commit is contained in:
wizardchen
2026-06-25 21:02:14 +08:00
committed by lyingbug
parent 1e16834d27
commit 9ca4e1f23a
16 changed files with 1247 additions and 673 deletions
+10 -3
View File
@@ -23,9 +23,13 @@ var (
ErrAgentNotConfigured = errors.New("agent is not fully configured (missing required chat model, or rerank model when the knowledge_search tool is enabled)")
)
// agentRequiresRerankModel returns true when the agent's configured tools
// will actually invoke the reranker at runtime. This mirrors the runtime
// check in session_agent_qa.go: only `knowledge_search` uses the reranker.
// agentRequiresRerankModel returns true when the agent's configured scope and
// tools will actually invoke the reranker at runtime. An agent whose knowledge
// base scope is explicitly disabled cannot run knowledge_search, so it does not
// need a rerank model even if that tool remains in AllowedTools.
//
// This mirrors the runtime check in session_agent_qa.go: only
// `knowledge_search` with an enabled knowledge-base scope uses the reranker.
// Wiki-first agents (wiki_search / wiki_read_page / …) never call it and
// therefore don't need a rerank model configured, even when knowledge bases
// are attached.
@@ -37,6 +41,9 @@ func agentRequiresRerankModel(agent *types.CustomAgent) bool {
if agent == nil {
return false
}
if agent.Config.KBSelectionMode == "none" {
return false
}
allowed := agent.Config.AllowedTools
if len(allowed) == 0 {
allowed = tools.DefaultAllowedTools()