Date: 2025-09-25
Status: Accepted
Deciders: AI Platform Team
Context#
Generating high-quality responses requires multiple specialized capabilities:
- Information retrieval (sources, citations)
- Teaching/instruction (persona style, pedagogy)
- Safety moderation (content policies)
- Audio narration (SSML preparation)
A single monolithic prompt cannot effectively handle all concerns.
Decision#
Implement a Multi-Agent System (MAS) where specialized agents collaborate:
Agents#
| Agent | Responsibility |
|---|---|
| Librarian | Query planning, source retrieval |
| Teacher | Response generation, persona style |
| Safety | Pre/post moderation |
| Narrator | SSML preparation for TTS |
Orchestration Pattern#
- Parallel Phase: Librarian + Safety pre-check run concurrently
- Generation Phase: Teacher generates with sources
- Moderation Phase: Safety post-check
- Narration Phase: Narrator prepares SSML (if audio)
Rationale#
Why Multi-Agent#
- Separation of concerns: Each agent optimized for its task
- Parallel execution: Reduces latency
- Modularity: Agents can be updated independently
- Testability: Each agent tested in isolation
Why This Agent Set#
- Librarian: Specialized for retrieval-augmented queries
- Teacher: Focus on pedagogical quality
- Safety: Dedicated to policy enforcement
- Narrator: TTS-specific optimizations
Alternatives Considered#
- Single Large Prompt: Too complex, hard to maintain
- Sequential Pipeline: Higher latency
- Router-only: Missing collaboration benefits
Consequences#
Positive#
- Better response quality
- Lower latency through parallelism
- Easier maintenance and testing
- Flexible agent composition
Negative#
- Coordination complexity
- More LLM calls (cost)
- Debug complexity
Mitigations#
- Comprehensive logging with correlation IDs
- Agent-level metrics
- Cost optimization through caching
Related#
- Algorithms - Multi-Agent Orchestration
- AI Service:
services/ai/