Tencent/WeKnora · error
no search targets available
Error message
no search targets available
What it means
KnowledgeSearch.Execute resolves the effective set of search targets (explicit knowledge_base_ids or the configured defaults). If neither is available it aborts with this error. It means the tool has no knowledge bases to search against at all.
Solutions
- Pass an explicit non-empty knowledge_base_ids array in the tool input
- Configure default search targets on the tool (t.searchTargets) at construction time
- Verify tenant/agent config that populates search targets is loaded correctly
Example fix
// before
Execute(ctx, map[string]any{"queries": []string{"refund policy"}}) // no KBs anywhere
// after
Execute(ctx, map[string]any{"queries": []string{"refund policy"}, "knowledge_base_ids": []string{"kb-123"}}) Defensive patterns
Strategy: validation
Validate before calling
if len(input.KnowledgeBaseIDs) == 0 && !searchTargetsConfigured {
return errors.New("knowledge_search requires KB ids or configured search targets")
} Type guard
func searchTargetsReady(t *KnowledgeSearchTool) bool {
return t != nil && t.searchTargets != nil && len(t.searchTargets.GetAllKnowledgeBaseIDs()) > 0
} Try / catch
res, err := tool.Execute(ctx, input)
if err != nil && strings.Contains(err.Error(), "no search targets available") {
log.Printf("configure search targets or pass knowledge_base_ids")
return res, nil
} Prevention
- Configure default search targets at tool construction
- Always pass explicit knowledge_base_ids in ephemeral setups
- Validate tenant/agent config loads search-target definitions
- Add a startup check that logs configured KB count
When it happens
Trigger: Calling knowledge_search with no knowledge_base_ids input while the tool was constructed with an empty/unset searchTargets configuration.
Common situations: Deployment where knowledge-base targets were never configured for the agent/tenant; caller forgets to pass KB IDs on a tool instance that has no defaults; config file section for search targets missing.
Related errors
- no queries provided
- all document retrievals failed
- chunk query returned no data
- CPU limit cannot be negative
- custom agent configuration is required for agent QA
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/637c6b365a515dda.
Report an issue: GitHub.
Appendix: source
Thrown at internal/agent/tools/knowledge_search.go:210
var filteredTargets types.SearchTargets
for _, target := range t.searchTargets {
if target == nil {
continue
}
if userKBSet[target.KnowledgeBaseID] {
filteredTargets = append(filteredTargets, target)
}
}
searchTargets = filteredTargets
}
// Validate search targets
if len(searchTargets) == 0 {
logger.Errorf(ctx, "[Tool][KnowledgeSearch] No search targets available")
return &types.ToolResult{
Success: false,
Error: "no knowledge bases specified and no search targets configured",
}, fmt.Errorf("no search targets available")
}
kbIDs := searchTargets.GetAllKnowledgeBaseIDs()
logger.Infof(ctx, "[Tool][KnowledgeSearch] Using %d search targets across %d KBs", len(searchTargets), len(kbIDs))
// Parse query parameter
queries := input.Queries
// Validate: query must be provided
if len(queries) == 0 {
logger.Errorf(ctx, "[Tool][KnowledgeSearch] No queries provided")
return &types.ToolResult{
Success: false,
Error: "queries parameter is required",
}, fmt.Errorf("no queries provided")
}
logger.Infof(ctx, "[Tool][KnowledgeSearch] Queries: %v", queries)View on GitHub (pinned to 988cbb0330)