Tencent/WeKnora · error
too many KB IDs
Error message
too many KB IDs
What it means
QueryKnowledgeGraph caps knowledge_base_ids at 10 per call to bound concurrent KB queries. Supplying more than 10 IDs returns this error before any query executes. The limit pairs with the validation that KBs must exist in the tool's search targets when scopeEnforced is set.
Source
Thrown at internal/agent/tools/query_knowledge_graph.go:129
Success: false,
Error: fmt.Sprintf("Failed to parse args: %v", err),
}, err
}
// Extract knowledge_base_ids array
if len(input.KnowledgeBaseIDs) == 0 {
return &types.ToolResult{
Success: false,
Error: "knowledge_base_ids is required and must be a non-empty array",
}, fmt.Errorf("knowledge_base_ids is required")
}
// Validate max 10 KBs
if len(input.KnowledgeBaseIDs) > 10 {
return &types.ToolResult{
Success: false,
Error: "knowledge_base_ids must contain at most 10 KB IDs",
}, fmt.Errorf("too many KB IDs")
}
if t.scopeEnforced {
if err := validateKnowledgeBaseIDsInSearchTargets(t.searchTargets, input.KnowledgeBaseIDs); err != nil {
return &types.ToolResult{Success: false, Error: err.Error()}, err
}
}
query := input.Query
if query == "" {
return &types.ToolResult{
Success: false,
Error: "query is required",
}, fmt.Errorf("invalid query")
}
// Concurrently query all knowledge bases
type graphQueryResult struct {
kbID stringView on GitHub (pinned to 988cbb0330)
Solutions
- Split the KB list into batches of at most 10 and issue multiple calls
- Pre-filter KBs to those likely relevant before calling
- Increase the cap only by modifying the tool's validation (requires code change) if legitimately needed
Example fix
// before
Execute(ctx, {"query": q, "knowledge_base_ids": allKBs}) // 25 KBs
// after
for batch := range chunk(allKBs, 10) {
Execute(ctx, {"query": q, "knowledge_base_ids": batch})
} Defensive patterns
Strategy: validation
Validate before calling
if len(kbIDs) > 10 { return fmt.Errorf("got %d KB ids, max is 10", len(kbIDs)) } Type guard
func withinKBLimit(ids []string) bool { return len(ids) >= 1 && len(ids) <= 10 } Try / catch
res, err := tool.Execute(ctx, input)
if err != nil && strings.Contains(err.Error(), "too many KB IDs") {
for _, batch := range chunk(kbIDs, 10) {
input["knowledge_base_ids"] = batch
res, err = tool.Execute(ctx, input)
if err != nil { break }
mergeResults(all, res)
}
} Prevention
- Batch KB IDs into groups of 10 before calling
- Pre-filter KBs by relevance instead of passing all of them
- Document the 10-KB cap in caller-side helpers
- Remember scopeEnforced also requires KBs to exist in search targets
When it happens
Trigger: Calling query_knowledge_graph with 11+ KB IDs in knowledge_base_ids.
Common situations: Caller dumps every KB in the tenant into the array instead of selecting relevant ones; batch scripts iterate over all KBs in one call rather than paging in groups of 10.
Related errors
- knowledge_base_ids is required
- invalid query
- missing query parameter
- no queries provided
- missing id parameter
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/b8881f82bcca8ab5.
Report an issue: GitHub.