Overview
mcp-agent provides two execution engines that determine how agent workflows are executed and managed. Each engine offers different capabilities for reliability, persistence, and deployment scenarios.Execution Engines
asyncio Engine
The asyncio engine runs workflows in-memory using Python’s native async/await capabilities. Characteristics:- In-memory execution
- No external dependencies
- Fast startup and iteration
- Best for development and simple deployments
- State lost on process restart
- Local development
- Quick prototyping
- Stateless operations
- Single-node deployments
Temporal Engine
The Temporal engine provides durable workflow execution with automatic state persistence. Characteristics:- Durable execution across restarts
- Automatic retry with exponential backoff
- Workflow history and replay
- Distributed execution support
- Requires Temporal server
- Production deployments
- Long-running workflows
- Critical operations requiring reliability
- Multi-node deployments
- Workflows requiring pause/resume
Executors
Executors are the runtime components that actually execute workflows within an engine.AsyncioExecutor
Handles workflow execution for the asyncio engine:- Direct Python function execution
- Native async/await support
- Minimal overhead
TemporalExecutor
Manages workflow execution for the Temporal engine:- Workflow versioning
- Activity retries
- Distributed execution
- Workflow queries and signals
Choosing an Execution Engine
Development Phase
Use asyncio engine during development:- Fast iteration cycles
- No infrastructure requirements
- Immediate feedback
- Simple debugging
Production Phase
Consider Temporal engine for production:- Workflow reliability
- Automatic failure handling
- Audit trail via workflow history
- Horizontal scaling
Execution Context
Both engines provide an execution context to workflows:Engine-Specific Features
asyncio Features
- Direct execution: Workflows run as standard Python functions
- Memory state: State maintained in process memory
- Simple cancellation: Standard asyncio cancellation
Temporal Features
- Workflow replay: Deterministic replay from history
- Signals: Send data to running workflows
- Queries: Query workflow state without affecting execution
- Child workflows: Spawn and manage child workflow instances
- Timers: Durable sleep and timeouts
- Activities: Retryable units of work
Migration Between Engines
Workflows written for mcp-agent can run on either engine without modification:Performance Considerations
asyncio Engine
- Latency: Microseconds for workflow start
- Throughput: Limited by single process
- Memory: All state in RAM
- Reliability: No persistence
Temporal Engine
- Latency: Milliseconds for workflow start
- Throughput: Horizontally scalable
- Memory: State persisted to database
- Reliability: Survives crashes and restarts