Architecture: What is the current state of the TenantAIService learning pi...
Documentation for Sessions
🏗️ Architecture: What is the current state of the TenantAIService learning pi...
Date: 2026-02-05
Time: 23:04:17 UTC
Session: editor2-92.26
Agent: backend
Confidence: 95%
Status: ✅ Documented
📋 Decision Context
Question:
What is the current state of the TenantAIService learning pipeline and what must future sessions wire?
Task: Session 93: Document TenantAIService wiring gap for future sessions
🎯 Decision Made
Chosen:
TenantAIService is ~80% coded but NEVER WIRED into any actual flow. It lives in backend-api (apis/backend-api/src/app/ai-agents/services/tenant-ai.service.ts) but is NOT registered in backend-ai-api's modules. All methods exist: getOrCreateProfile(), logInteraction() (with embeddings), addFeedback() (learns successful approaches/anti-patterns), getPersonalizationContext() (3-tier: profile + recent successful + semantic few-shot), findSimilarInteractions() (cosine similarity > 0.5), learnTechStackFromCode(), learnSuccessfulApproach(), learnAntiPattern(). Phase 3 must: register TenantAIService in backend-ai-api, make it space-aware (add spaceId param to all methods, use SpaceAIDatabaseService when spaceId present), wire it into Vitto's saveUserLearning() and processHandoff() flows, and call getPersonalizationContext() before generating AI responses.
Options Considered:
- No alternatives documented
💭 Reasoning
This is the most critical orphaned code in the system. The learning code exists but produces zero value because nothing calls it. The Session 93 foundation (SpaceAIDatabaseService, spaceId on schemas, auth claims) unblocks Phase 3 wiring. Future agents MUST understand: (1) TenantAIService currently writes to global ai-agents DB via injected models — it needs to be made space-aware by checking spaceId and routing to SpaceAIDatabaseService. (2) Vitto's saveUserLearning() currently only stores interaction type with fixed 0.5 confidence — it needs enrichment with real signals (outcome, files modified, duration, tools used). (3) The 3-tier personalization context (user profile + recent successful interactions + semantic few-shot examples) is already coded in getPersonalizationContext() and just needs to be called before AI response generation.
📁 Files Involved
apis/backend-api/src/app/ai-agents/services/tenant-ai.service.tsapis/backend-ai-api/src/app/vitto/vitto-orchestrator.service.tsapis/backend-ai-api/src/app/agents/services/space-ai-database.service.ts
🔗 Related
- Decision ID:
dev_1770332657608_0lg6d5m - Session: 92
- Workspace: editor2
Auto-generated by MCP Smart Consolidation