Implementation: How should TenantAIService resolve between global (ai-agents...

Documentation for Sessions

⚙️ Implementation: How should TenantAIService resolve between global (ai-agents...

Date: 2026-02-05
Time: 23:22:32 UTC
Session: editor2-93.3
Agent: angular
Confidence: 95%
Status: ✅ Documented


📋 Decision Context

Question:

How should TenantAIService resolve between global (ai-agents) and space-scoped (space-agents_{spaceId}) models?

Task: Session 93.2: Wire TenantAIService learning pipelines into Vitto and Space Agent flows


🎯 Decision Made

Chosen:

Private resolveProfileModel(spaceId?) and resolveInteractionModel(spaceId?) methods that check spaceId presence → SpaceAIDatabaseService when present, global injected model otherwise

Options Considered:

  1. resolve methods with spaceId check
  2. separate SpaceTenantAIService subclass
  3. middleware/interceptor to swap model at request level
  4. pass model explicitly from caller

💭 Reasoning

Every public method gets an optional spaceId parameter. The resolve methods encapsulate the routing decision in one place. When spaceId is present + SpaceAIDatabaseService is available, it uses the space-scoped model. Otherwise falls back to the global model (ai-agents DB). This keeps the routing rule (spaceId present → space DB, absent → global DB) consistent across all 12+ methods without duplicating the logic.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation