Skip to content

IAV-241/refactor: convert Agent to abstract class with family-specific inheritance

salaheddine zidani a demandé de fusionner feature/IAV-241 vers develop

🎯 Objective

Refactor the Agent entity architecture to support multiple agent families through inheritance, improving code organization and type safety.

📋 Changes

Architecture

  • Converted Agent from concrete entity to abstract base class
  • Implemented JOINED inheritance strategy for agent families
  • Created CustomerCareAgent as 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:
    • languagesAgentLanguage
    • conversationSessionsConversationSession

CustomerCareAgent (Concrete Implementation)

  • Extends Agent with customer care specific features:
    • toneVoice, responseStyle, blockedKeywords
  • Family-specific relationships:
    • integrationsAgentIntegration
    • faqsFaq
    • standardInstructionsAgentStandardInstruction
    • customInstructionsAgentCustomInstruction
    • agentWorkingHoursAgentWorkingHours
    • ticketsTicket
  • Hierarchical relationships (parent/sub-agents)

Package Reorganization

  • Moved ToneVoice and ResponseStyle enumerations to customerCare.enumerations
  • Family-specific entities updated to reference CustomerCareAgent instead of Agent

Database Schema

  • New table: customer_care_agents (primary key joins with agents.id)
  • Updated foreign key constraints for family-specific relationships
  • New collection table: customer_care_agent_blocked_keywords

🎁 Benefits

  1. Better Separation of Concerns: Each agent family has its own entity with specific fields
  2. Type Safety: Compile-time checking for family-specific relationships
  3. Scalability: Easy to add new agent families without polluting base class
  4. Cleaner Code: No more null checks for family-specific fields
  5. Explicit Relationships: Clear ownership of family-specific entities

️ Breaking Changes

  • Agent entity 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 CustomerCareAgent instead of Agent

📚 Related Issues

Closes IAV-241

Rapports de requête de fusion