fix(agent): relax rerank model requirement for custom agents

Previously the custom agent editor hid the rerank model field when no
RAG-type knowledge base existed in the configured scope, but the
not-ready check and runtime hard-failed whenever knowledge_search was
in allowed_tools. Users with wiki-only or empty scopes saw "Rerank
Model required" warnings they could not resolve, and "All knowledge
bases" agents broke later if a RAG-type KB was added.

- Backend: when knowledge_search is enabled, fall back to the tenant
  default rerank model (ConversationConfig.RerankModelID) before
  erroring out, matching the built-in agent behaviour.
- Editor: always show the rerank field once a KB scope is selected;
  only mark it required (red *) when the scope contains a RAG KB, with
  a hint explaining the tenant-default fallback.
- Editor: only render rerank top_k / threshold sliders when a rerank
  model is actually selected.
- Input field: drop the eager "missing rerank" not-ready reason; the
  backend is now the single source of truth for rerank availability.
- i18n: add agent.editor.rerankModelOptionalHint across all locales.
This commit is contained in:
wizardchen
2026-05-12 16:41:36 +08:00
committed by lyingbug
parent 4ed7b90eac
commit 5949be739f
7 changed files with 43 additions and 18 deletions
@@ -100,10 +100,21 @@ func (s *sessionService) AgentQA(
}
if hasKnowledgeSearchTool {
// Resolve rerank model: agent-level first, then fall back to tenant default
// (ConversationConfig.RerankModelID). This lets users leave rerank empty when
// their KB scope currently has no RAG-type KB, while still working correctly
// if a RAG-type KB is added later.
rerankModelID := req.CustomAgent.Config.RerankModelID
if rerankModelID == "" && tenantInfo != nil && tenantInfo.ConversationConfig != nil {
rerankModelID = tenantInfo.ConversationConfig.RerankModelID
if rerankModelID != "" {
logger.Infof(ctx, "Custom agent %s has no rerank model; falling back to tenant default rerank model %s",
req.CustomAgent.ID, rerankModelID)
}
}
if rerankModelID == "" {
logger.Warnf(ctx, "No rerank model configured for custom agent %s, but knowledge_search tool is enabled", req.CustomAgent.ID)
return errors.New("rerank model (rerank_model_id) is not configured in custom agent settings")
logger.Warnf(ctx, "No rerank model configured for custom agent %s (and no tenant default), but knowledge_search tool is enabled", req.CustomAgent.ID)
return errors.New("rerank model is not configured: please set rerank_model_id on the agent or configure a tenant default rerank model")
}
rerankModel, err = s.modelService.GetRerankModel(ctx, rerankModelID)