fix(search): harden tag scope resolution after #1907

Default missing KB metadata to document tag relation lookup, propagate tag resolution failures instead of returning empty results, and reject ambiguous bare tag_ids when multiple knowledge bases are in scope.
This commit is contained in:
wizardchen
2026-07-06 23:38:43 +08:00
committed by lyingbug
parent 0db71bf2f8
commit d9bb7aa8f2
6 changed files with 142 additions and 22 deletions
@@ -304,7 +304,7 @@ func (s *sessionService) buildAgentConfig(
// Build search targets using agent's tenant (handler has validated access for shared agent)
searchTargets, err := s.buildSearchTargets(ctx, agentTenantID, agentConfig.KnowledgeBases, agentConfig.KnowledgeIDs, req.TagScopes)
if err != nil {
logger.Warnf(ctx, "Failed to build search targets for agent: %v", err)
return nil, fmt.Errorf("build search targets: %w", err)
}
agentConfig.SearchTargets = searchTargets
logger.Infof(ctx, "Agent search targets built: %d targets", len(searchTargets))