Overview
Concrete tool for executing multi-agent workflow graphs with DAG traversal, environment state management, and optional human-in-the-loop integration.
Description
The WorkFlow class is the execution engine for WorkFlowGraph instances. It traverses the DAG by scheduling nodes via WorkFlowManager, executes each node either by agent-based execution or action-graph execution, and tracks all execution data in an Environment. It supports both synchronous (`execute()`) and asynchronous (`async_execute()`) execution, with HITL integration when an HITLManager is provided. The result is a WorkflowResult with status, result data, and error info.
Usage
- Auto-generated workflows: Execute a graph from `WorkFlowGenerator` with an `AgentManager` populated via `add_agents_from_workflow`.
- Sequential workflows: Execute a `SequentialWorkFlowGraph` with manually defined task nodes.
- HITL workflows: Pass `hitl_manager=hitl_manager` to enable human approval checkpoints at interceptor nodes.
- Benchmark evaluation: The `Evaluator` class internally creates `WorkFlow` instances to evaluate `WorkFlowGraph` against benchmarks.
Code Reference
Source Location
- Repository: EvoAgentX
- File: evoagentx/workflow/workflow.py (L32-540)
Signature
class WorkflowResult(BaseModule):
status: Literal["success", "failed"]
result: Optional[Union[dict, str]] = None
error_msg: Optional[str] = None
displayable_error: Optional[str] = None
class WorkFlow(BaseModule):
graph: WorkFlowGraph
llm: Optional[BaseLLM] = None
agent_manager: AgentManager = None
workflow_manager: Optional[WorkFlowManager] = None
environment: Environment = Environment()
storage_handler: Optional[StorageHandler] = None
max_execution_steps: int = 5
hitl_manager: Optional[HITLManager] = None
def execute(self, inputs: Optional[dict] = None, extract_output: bool = False, **kwargs) -> WorkflowResult
async def async_execute(self, inputs: Optional[dict] = None, extract_output: bool = False, **kwargs) -> WorkflowResult
Import
from evoagentx.workflow.workflow import WorkFlow, WorkflowResult
I/O Contract
Inputs
| Name |
Type |
Required |
Description
|
| graph |
WorkFlowGraph |
Yes |
DAG of nodes and edges
|
| llm |
BaseLLM |
Yes (if no workflow_manager) |
LLM for task scheduling
|
| agent_manager |
AgentManager |
Yes (for agent-based nodes) |
Manages agents referenced by nodes
|
| hitl_manager |
HITLManager |
No |
Active HITL manager for human checkpoints
|
| inputs |
dict |
No |
Runtime input values matching `graph.workflow_inputs`
|
| extract_output |
bool |
No |
Use LLM to extract final output as string
|
| max_execution_steps |
int |
No |
Max steps per node (default: 5)
|
Outputs
| Name |
Type |
Description
|
| execute returns |
WorkflowResult |
Contains status, result dict/str, error_msg, displayable_error
|
Usage Examples
Execute Generated Workflow
from evoagentx.workflow.workflow import WorkFlow
from evoagentx.agents.agent_manager import AgentManager
from evoagentx.models.model_configs import OpenRouterConfig
# graph generated by WorkFlowGenerator
llm_config = OpenRouterConfig(model="anthropic/claude-3.5-sonnet", openrouter_key="sk-or-...")
agent_manager = AgentManager()
agent_manager.add_agents_from_workflow(graph, llm_config=llm_config)
workflow = WorkFlow(
graph=graph,
llm=llm,
agent_manager=agent_manager,
)
result = workflow.execute(inputs={"topic": "LLM agents"})
print(result.status, result.result)
Execute with HITL
from evoagentx.workflow.workflow import WorkFlow
from evoagentx.hitl.approval_manager import HITLManager
hitl_manager = HITLManager()
hitl_manager.activate()
workflow = WorkFlow(
graph=graph,
llm=llm,
agent_manager=agent_manager,
hitl_manager=hitl_manager,
)
result = workflow.execute(inputs={"topic": "LLM agents"})
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.