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
@@ -0,0 +1,68 @@
package service
import (
"testing"
"github.com/Tencent/WeKnora/internal/agent/tools"
"github.com/Tencent/WeKnora/internal/types"
"github.com/stretchr/testify/assert"
)
func TestAgentRequiresRerankModel(t *testing.T) {
tests := []struct {
name string
agent *types.CustomAgent
want bool
}{
{
name: "knowledge search with all knowledge bases",
agent: &types.CustomAgent{Config: types.CustomAgentConfig{
KBSelectionMode: "all",
AllowedTools: []string{tools.ToolKnowledgeSearch},
}},
want: true,
},
{
name: "knowledge search with selected knowledge bases",
agent: &types.CustomAgent{Config: types.CustomAgentConfig{
KBSelectionMode: "selected",
AllowedTools: []string{tools.ToolKnowledgeSearch},
}},
want: true,
},
{
name: "knowledge search with knowledge bases disabled",
agent: &types.CustomAgent{Config: types.CustomAgentConfig{
KBSelectionMode: "none",
AllowedTools: []string{tools.ToolKnowledgeSearch},
}},
want: false,
},
{
name: "default tools with knowledge bases disabled",
agent: &types.CustomAgent{Config: types.CustomAgentConfig{
KBSelectionMode: "none",
}},
want: false,
},
{
name: "wiki tools do not use reranker",
agent: &types.CustomAgent{Config: types.CustomAgentConfig{
KBSelectionMode: "all",
AllowedTools: []string{"wiki_search", "wiki_read_page"},
}},
want: false,
},
{
name: "nil agent",
agent: nil,
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.want, agentRequiresRerankModel(tt.agent))
})
}
}