refactor(api): drop deprecated tenant ConversationConfig field and KV write path

The Tenant.ConversationConfig field was marked deprecated when
CustomAgent (builtin-quick-answer) replaced the per-tenant defaults
path, but the JSONB column, GET/PUT KV handlers, write helpers and
read fall-throughs all stayed wired. This had two concrete failure
modes:

  - Input-field.vue silently PUT-ed per-user model picks back into
    /tenants/kv/conversation-config, which requires Admin+ — Viewers
    and Contributors got a 403 every time they switched chat models.
  - The same write also overwrote the tenant-shared default for every
    other user, turning a per-user UX into a per-tenant footgun.

Remove the field, the struct, the validate helper, the PUT case and
the two dead Summary helpers in session/helpers.go. KnowledgeSearch
loses its tenant-conversation fallback (one chunk-tool reader); the
global config + hardcoded defaults still cover it. session_agent_qa
already required agents to declare their own rerank_model_id, so no
behaviour change there.

Frontend follows:
  - Input-field.vue: per-user 'last selected chat model' moves to
    localStorage, no API call.
  - AgentEditorModal: defaults for builtin-quick-answer creation now
    come from prompt-templates (system/context/rewrite/fallback) and
    retrieval-config (top_k / threshold), the two endpoints that
    actually own those settings now.
  - AgentSettings.vue: orphan settings page with no router/import
    referencing it; deleted.
  - api/system: getConversationConfig / updateConversationConfig and
    the ConversationConfig interface go away.

Net: 137 insertions, 2761 deletions.
This commit is contained in:
wizardchen
2026-05-15 12:14:53 +08:00
committed by lyingbug
parent b0b7cfa351
commit 1e8b5c8d40
9 changed files with 138 additions and 2762 deletions
@@ -100,21 +100,19 @@ 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.
// Rerank model is resolved purely from the agent config now.
// We used to fall back to ConversationConfig.RerankModelID at
// the tenant level, but that path encouraged "leave rerank
// blank on the agent and inherit silently" which made debugging
// retrieval quality a guessing game across tenant settings vs
// agent settings. Forcing the agent to declare its own rerank
// model puts the configuration where the user actually edits
// the agent. If a Wiki-only agent doesn't need reranking,
// agentRequiresRerankModel() below already lets it pass.
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 (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")
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 is not configured: please set rerank_model_id on the agent")
}
rerankModel, err = s.modelService.GetRerankModel(ctx, rerankModelID)