Agent Runtime
Motor de ejecución central. AgentRuntime gestiona el ciclo de vida de un agente: LLM, tools, verificación, checkpoints y reintentos bajo presupuestos de tokens y pasos.
Flujo
AgentRuntime.execute(ctx)
│
├─ acquireSlot() / tenant checks / storage
├─ [Retry loop]
│ ├─ callWithTimeout() → LLM
│ ├─ ToolPlanner → executeTool → cache
│ ├─ verification (5 puertas)
│ └─ checkpoint()
├─ releaseSlot()
└─ flush tracesBucle principal
- Semáforo de concurrencia
- Rate limit y cuota por tenant
- Llamada LLM con timeout
- Tools con plan de dependencias (paralelo cuando es posible)
- Verificación de 5 puertas → reintento si falla
- Checkpoint atómico por paso
- Flush de traces y muestras
Componentes
| Componente | Archivo | Rol |
|---|---|---|
AgentRuntime | runtime/agentRuntime.ts | Bucle principal |
ToolPlanner | runtime/toolPlanner.ts | Plan de tools |
ToolOrchestrator | runtime/toolOrchestrator.ts | Ejecuta el plan |
StepErrorBoundary | runtime/stepErrorBoundary.ts | skip/retry/abort |
TokenGovernor | runtime/tokenGovernor.ts | Presupuesto de tokens |
CycleDetector | runtime/cycleDetector.ts | Bucles infinitos |
Config
typescript
interface AgentRuntimeConfig {
maxStepsPerRun: number;
maxRetries: number;
timeoutMs: number;
maxConcurrency: number;
budgetHardCapTokens: number;
}