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:
- resolve methods with spaceId check
- separate SpaceTenantAIService subclass
- middleware/interceptor to swap model at request level
- 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
apis/backend-ai-api/src/app/agents/services/tenant-ai.service.ts
🔗 Related
- Decision ID:
dev_1770333752893_7uktmlt - Session: 93
- Workspace: editor2
Auto-generated by MCP Smart Consolidation