IAV-241/refactor: convert Agent to abstract class with family-specific inheritance
🎯 Objective
Refactor the Agent entity architecture to support multiple agent families through inheritance, improving code organization and type safety.
📋 Changes
Architecture
- Converted
Agentfrom concrete entity to abstract base class - Implemented JOINED inheritance strategy for agent families
- Created
CustomerCareAgentas first family-specific implementation
Entity Changes
Agent (Abstract Base Class)
- Contains fields common to all agent families:
-
displayName,description,family,type -
ownerUserUid,createdBy,systemPrompt -
active,knowledgeDocumentsUid
-
- Maintains common relationships:
-
languages→AgentLanguage -
conversationSessions→ConversationSession
-
CustomerCareAgent (Concrete Implementation)
- Extends
Agentwith customer care specific features:-
toneVoice,responseStyle,blockedKeywords
-
- Family-specific relationships:
-
integrations→AgentIntegration -
faqs→Faq -
standardInstructions→AgentStandardInstruction -
customInstructions→AgentCustomInstruction -
agentWorkingHours→AgentWorkingHours -
tickets→Ticket
-
- Hierarchical relationships (parent/sub-agents)
Package Reorganization
- Moved
ToneVoiceandResponseStyleenumerations tocustomerCare.enumerations - Family-specific entities updated to reference
CustomerCareAgentinstead ofAgent
Database Schema
- New table:
customer_care_agents(primary key joins withagents.id) - Updated foreign key constraints for family-specific relationships
- New collection table:
customer_care_agent_blocked_keywords
🎁 Benefits
- Better Separation of Concerns: Each agent family has its own entity with specific fields
- Type Safety: Compile-time checking for family-specific relationships
- Scalability: Easy to add new agent families without polluting base class
- Cleaner Code: No more null checks for family-specific fields
- Explicit Relationships: Clear ownership of family-specific entities
⚠ ️ Breaking Changes
-
Agententity is now abstract and cannot be instantiated directly - Services and repositories must use family-specific agent classes (e.g.,
CustomerCareAgent) - Family-specific entities (Faq, Ticket, etc.) now reference
CustomerCareAgentinstead ofAgent
📚 Related Issues
Closes IAV-241