""" Base Agent Module ================== Abstract base class for all agents in the system. """ from abc import ABC, abstractmethod from dataclasses import dataclass, field from typing import Any import logging import uuid # Configure logging logging.basicConfig(level=logging.INFO) @dataclass class BaseAgent(ABC): """ Abstract base class for all agents. Attributes: id: Unique identifier for the agent instance role: The role/purpose of this agent tools: List of tool names this agent can use """ role: str tools: list[str] = field(default_factory=list) id: str = field(default_factory=lambda: str(uuid.uuid4())[:8]) def __post_init__(self): self.logger = logging.getLogger(f"Agent-{self.role}-{self.id}") @abstractmethod async def run(self, input: dict[str, Any]) -> dict[str, Any]: """ Execute the agent's main task. Args: input: Dictionary containing input parameters for the agent Returns: Dictionary containing the agent's output/results """ pass def log(self, message: str, level: str = "info"): """Log a message with the agent's context.""" getattr(self.logger, level)(f"[{self.role}] {message}")