Skip to main content

ExecutionLimits

ExecutionLimits(
    max_budget: float | None = None,       # Max spend in dollars
    max_steps: int | None = None,          # Max LLM calls
    max_time_seconds: float | None = None, # Max wall-clock time
    per_agent_max_steps: int | None = None,
    per_agent_max_budget: float | None = None,
)

LoopDetectionConfig

LoopDetectionConfig(
    max_repeated_outputs: int = 3,  # Same output N times
    max_no_state_change: int = 5,   # No change N times
    max_ping_pong: int = 4,         # A↔B cycles
    window_size: int = 20,          # Recent steps to analyze
)

MemoryConfig

MemoryConfig(
    max_size_bytes: int = 10 * 1024 * 1024,  # 10MB
    ttl_seconds: float | None = 3600,         # 1 hour
    eviction_policy: str = "fifo",            # fifo, lru, ttl
    max_entries: int | None = 1000,
)

LLMProvider

class LLMProvider(Enum):
    OPENAI = "openai"
    ANTHROPIC = "anthropic"
    GEMINI = "gemini"
    MOCK = "mock"

LLMMessage

LLMMessage(
    role: str,           # system, user, assistant, tool
    content: str,
    name: str | None = None,
    tool_call_id: str | None = None,
)

LLMRequest

LLMRequest(
    provider: LLMProvider,
    model: str,
    messages: list[LLMMessage],
    tools: list[dict] | None = None,
    temperature: float | None = None,
    max_tokens: int | None = None,
)

LLMResponse

LLMResponse(
    content: str | None = None,
    tool_calls: list[dict] | None = None,
    input_tokens: int = 0,
    output_tokens: int = 0,
    cost: float = 0.0,
    model: str,
    provider: LLMProvider,
    latency_ms: float = 0.0,
)

ExecutionMetrics

ExecutionMetrics(
    total_cost: float = 0.0,
    total_steps: int = 0,
    total_tokens: int = 0,
    input_tokens: int = 0,
    output_tokens: int = 0,
    start_time: datetime | None = None,
    elapsed_seconds: float = 0.0,
)

Exceptions

ExceptionWhen Raised
BudgetExceededErrorBudget limit exceeded
StepLimitExceededErrorStep limit exceeded
TimeLimitExceededErrorTime limit exceeded
LoopDetectedErrorLoop pattern detected
ToolAccessDeniedErrorAgent can’t use tool
StateOwnershipErrorAgent can’t write field
SchemaValidationErrorInvalid handoff data
ProviderNotFoundErrorProvider not configured
WorkflowExecutionErrorWorkflow failed