Executing Agents & Workflows
How to trigger agents and workflows, check status, and retrieve results.
#Execute an Agent
python
# Fire and forget — returns immediately with an execution_id
result = client.execute_agent("my_agent", data={"input": "hello"})
print(result.execution_id)
# Block until complete
result = client.execute_agent("my_agent", data={"input": "hello"}, wait=True)
print(result.result)#Execute a Workflow
python
result = client.execute_workflow("my_workflow", data={"input": "data"}, wait=True)
print(result.result)#Check Execution Status
python
execution = client.get_execution("exec_abc123")
print(execution.status) # queued | running | completed | failed | cancelled#Wait for a Running Execution
python
final = client.wait_for_execution("exec_abc123", timeout=120)
print(final.result)#List Executions
python
# Recent executions
executions = client.list_executions(limit=20)
# Filter by agent and status
executions = client.list_executions(agent_name="my_agent", status="completed")
# Get the latest result for a specific agent
latest = client.get_latest_execution(agent_name="my_agent")
print(latest.result)#Cancel an Execution
python
client.cancel_execution("exec_abc123")