Tencent/WeKnora · error

cannot choose a knowledge base for new wiki page %s from %d

Error message

cannot choose a knowledge base for new wiki page %s from %d allowed scopes

What it means

When there are no conflicting provenance owners but more than one (or zero) allowed KB scopes, resolveWikiCreateKB cannot infer a unique creation target and fails with this error naming the scope count. It is the resolver's 'the model must tell me which KB to create in' error.

Source

Thrown at internal/agent/tools/wiki_route_resolver.go:207

	for _, kbID := range serverHints {
		if _, ok := allowed[kbID]; ok {
			candidates = append(candidates, kbID)
		}
	}
	candidates = dedupNonEmptyStrings(candidates)
	if len(candidates) == 1 {
		return candidates[0], nil
	}
	if len(candidates) > 1 {
		return "", fmt.Errorf(
			"cannot choose a knowledge base for new wiki page %s: server provenance conflicts across %s",
			slug, strings.Join(candidates, ", "),
		)
	}
	if len(scopes) == 1 {
		return scopes[0].KnowledgeBaseID, nil
	}
	return "", fmt.Errorf("cannot choose a knowledge base for new wiki page %s from %d allowed scopes", slug, len(scopes))
}

func wikiKnowledgeBasesForSourceRefs(
	ctx context.Context,
	refs []string,
	knowledgeService interfaces.KnowledgeService,
	allowedKBIDs []string,
) ([]string, error) {
	if len(refs) == 0 {
		return nil, nil
	}
	if knowledgeService == nil {
		return nil, fmt.Errorf("knowledge service is unavailable")
	}
	allowed := make(map[string]struct{}, len(allowedKBIDs))
	for _, kbID := range dedupNonEmptyStrings(allowedKBIDs) {
		allowed[kbID] = struct{}{}
	}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Have the tool require/ask for the target knowledge_base_id when more than one KB is in scope
  2. Restrict the agent's wiki scopes to a single KB if all writes target one space
  3. Create the page first in a pinned KB and reuse its provenance for follow-ups
  4. Surface the scope count to the model so it can disambiguate on the next turn

Example fix

// tool argument handling
kbArg, _ := args["knowledge_base_id"].(string)
if kbArg == "" && len(scopes) != 1 {
    return &types.ToolResult{Success: false, Error: fmt.Sprintf("specify a knowledge base (%d allowed)", len(scopes))}, nil
}
kbID, err := resolveWikiCreateKB(ctx, slug, scopes, routes)
Defensive patterns

Strategy: validation

Validate before calling

kbArg, _ := args["knowledge_base_id"].(string)
if kbArg == "" && len(allowedScopes) != 1 {
    return &types.ToolResult{Success: false,
        Error: fmt.Sprintf("specify one of %d allowed knowledge bases for creation", len(allowedScopes))}, nil
}

Type guard

null

Try / catch

kbID, err := resolveWikiCreateKB(ctx, slug, scopes, routes)
if err != nil && strings.Contains(err.Error(), "allowed scopes") {
    // re-prompt with the scope list so the model can choose a KB
}

Prevention

When it happens

Trigger: Create call with a novel slug (no server provenance) while the request allows len(scopes) != 1 knowledge bases — e.g. 0 or 2+ KBs in scope.

Common situations: Agent session authorized across several KBs and the model omitted the target KB; slug never used before so there is no cached owner; scopes misconfigured to include extra KBs.

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/7300f675f3fc5e81. Report an issue: GitHub.