Design Production-Ready Agent System

Hard
Agents

Design and implement a production-ready agent system:

Architecture Components:

  1. Orchestrator: Central task dispatch
  2. Memory: Tiered storage (STM/LTM/Vector)
  3. Tool Registry: Sandboxed execution
  4. Safety: Multi-layer guardrails
  5. Observability: Metrics, logging, tracing

Requirements:

  1. initialize_components(): Set up all subsystems
  2. execute_task(task, context): Full execution pipeline
    • Generate trace_id
    • Run safety checks
    • Execute with observability
    • Return result + metrics
  3. health_check(): Verify all components healthy
  4. graceful_shutdown(): Clean resource cleanup

Production Considerations:

  • Circuit breakers on external calls
  • Token budget enforcement
  • Rate limiting
  • Error recovery
  • Audit logging

Examples

Example 1:
Input: config = {'max_tokens': 1000, 'timeout': 30}; system = ProductionAgentSystem(config); system.initialize_components(); 'orchestrator' in system.components
Output: True
Explanation: System initialized with orchestrator component

Starter Code

class ProductionAgentSystem:
    """
    Design a production-ready agent system with all components.
    This is a system design implementation.
    """
    
    def __init__(self, config):
        self.config = config
        self.components = {}
        self.health_status = {}
    
    def initialize_components(self):
        """
        Initialize all system components:
        - Agent orchestrator
        - Memory systems (short/long-term)
        - Tool registry with sandboxing
        - Safety guardrails
        - Observability
        """
        # Your implementation here
        pass
    
    def execute_task(self, task, context=None):
        """
        Execute task with full observability and safety.
        Returns {'result': ..., 'trace_id': ..., 'metrics': ...}
        """
        # Your implementation here
        pass
    
    def health_check(self):
        """Check health of all components"""
        # Your implementation here
        pass
    
    def graceful_shutdown(self):
        """Gracefully shutdown all components"""
        # Your implementation here
        pass
Lines: 1Characters: 0
Ready
The AI Interview - Master AI/ML Interviews