Building Agentic Workflows with OpenCLAW: From Triggers to Multi-Agent Orchestration
Agentic AI systems move beyond single-model calls — they observe data, make decisions, delegate work, and persist findings across runs. OpenCLAW is the runtime that makes this practical. It gives you a structured way to compose agents into workflows driven by real data events, not hand-rolled polling loops.
This tutorial walks through the full stack: entity event triggers, multi-step workflow DAGs, agent-to-agent (A2A) communication patterns, and parallel orchestration — with concrete configuration examples at each step.
What OpenCLAW Actually Is
OpenCLAW is an agentic platform where agents share a persistent workspace. That workspace contains:
- Entity records — structured rows keyed by
entity_type+entity_id, queryable and writable by any agent - Memory zones —
northstar:*(read-only config),shared:*(cross-agent), and private namespaces per agent - Knowledge graph — typed edges between entities (
WORKS_AT,MANAGES,OWNS, etc.) - A2A messaging — async messages between agents with typed payloads
- Workflow engine — multi-step DAGs with triggers, conditions, delays, and agent actions
Agents run on a schedule or in response to events. They call tools to read/write data, delegate to other agents, and route findings. The runtime enforces blast-radius controls, tool budgets, and memory decay policies — so you can safely compose agents without building your own guardrails.
Triggers: Starting Points for Automation
OpenCLAW supports two trigger types:
Entity Event Triggers
Fire when a record is created, updated, or deleted:
{
"entity_type": "deals",
"event": "updated",
"conditions": {
"status": "closed_won"
},
"agent_id": "revenue-analyst",
"prompt_template": "Deal {{entity_id}} just closed. Analyze ARR impact and update the forecast."
}
Use adl_create_trigger to register this. The agent wakes within seconds of the matching CDC event.
Schedule Triggers
Run agents on a cron schedule — daily reports, weekly digests, periodic health checks:
{
"schedule": "0 8 * * 1",
"agent_id": "blog-writer",
"prompt": "Scheduled run: check editorial calendar and produce this week's post."
}
Before creating any trigger, call adl_list_triggers to check what's already automated. Duplicate triggers produce duplicate runs.
Workflows: Multi-Step DAGs
For sequences that need conditions, delays, or branching, use workflows instead of raw triggers.
A workflow is a graph of nodes connected by edges:
| Node type | Purpose |
|---|---|
data_trigger | Start when an entity event fires |
schedule_trigger | Start on a cron schedule |
agent_action | Invoke an agent with a prompt |
condition | Branch on a field value (if/else) |
delay | Wait N seconds/minutes before continuing |
Example: Onboarding Pipeline
This workflow fires when a new contact is created, checks their company tier, and routes to different onboarding agents:
{
"name": "new-contact-onboarding",
"nodes": [
{
"id": "trigger",
"type": "data_trigger",
"config": { "entity_type": "contacts", "event": "created" }
},
{
"id": "check_tier",
"type": "condition",
"config": {
"field": "company_tier",
"operator": "eq",
"value": "enterprise"
}
},
{
"id": "enterprise_onboarding",
"type": "agent_action",
"config": {
"agent_id": "enterprise-csm",
"prompt": "New enterprise contact {{entity_id}} created. Kick off white-glove onboarding."
}
},
{
"id": "standard_onboarding",
"type": "agent_action",
"config": {
"agent_id": "self-serve-csm",
"prompt": "New contact {{entity_id}} created. Send welcome sequence."
}
}
],
"edges": [
{ "from": "trigger", "to": "check_tier" },
{ "from": "check_tier", "to": "enterprise_onboarding", "condition": "true" },
{ "from": "check_tier", "to": "standard_onboarding", "condition": "false" }
]
}
Create this with adl_create_workflow, then deploy with adl_deploy_workflow. Workflows start as draft — they don't run until deployed.
State machine: draft → deployed → paused → (update) → deployed
Only draft or paused workflows can be updated. Deployed workflows must be paused first.
Agent-to-Agent (A2A) Communication
Agents coordinate through three channels:
1. Async Messages (adl_send_message)
For notifications, findings, and requests that don't need an immediate response:
adl_send_message(
recipient_agent_id="marketing-growth",
message_type="finding",
body={
"title": "Q2 Pipeline Report Ready",
"entity_type": "reports",
"entity_id": "rpt_20260601_001",
"summary": "Pipeline up 18% QoQ. See record for full breakdown."
}
)
Send compact DataParts — a reference to the entity record, not the full payload. The recipient fetches on demand.
Hub-and-spoke routing: When agents are in the same team but different domains, messages route through the team lead automatically. Use direct=true + bypass_reason only for genuine production alerts.
2. Sync Delegation (adl_run_agent)
For urgent subtasks where you need the result inline:
result = adl_run_agent(
agent_id="data-analyst",
prompt="Compute churn rate for cohort {{cohort_id}} and return the percentage.",
context={"cohort_id": "cohort_2026_q1"},
wait=True,
timeout_seconds=120
)
Max 3 spawns per run — use sparingly. Don't delegate 1-2-tool-call work.
3. Task-Based Delegation (Kanban)
For trackable, retryable work:
adl_upsert_record(
entity_type="tasks",
entity_id="task_20260523_001",
data={
"title": "Generate weekly SEO report",
"assignee_agent_id": "seo-expert",
"priority": "high",
"acceptance_criteria": "Return top 10 keyword rankings and 3 content gaps.",
"due_date": "2026-05-30"
}
)
The platform auto-wakes the assigned agent within 60 seconds. The task appears on the workspace kanban board — visible to humans and agents alike.
Parallel Orchestration
When subtasks are independent, run them in parallel with adl_run_agents:
results = adl_run_agents(
tasks=[
{
"agent_id": "seo-expert",
"prompt": "Analyze keyword gaps for 'agentic AI workflows'",
"context": {"target_url": "/blog/agentic-workflows"}
},
{
"agent_id": "social-media-strategist",
"prompt": "Draft 3 social posts for the new agentic workflows blog post",
"context": {"post_title": "Building Agentic Workflows with OpenCLAW"}
},
{
"agent_id": "marketing-growth",
"prompt": "Add new blog post to Q2 promotion calendar",
"context": {"publish_date": "2026-05-28"}
}
],
wait=True,
timeout_seconds=180
)
All three run concurrently. Collect results from the returned array.
Cap: 3 spawns per run total — across adl_run_agent and adl_run_agents combined.
Real-World Pattern: CDC-Driven Analysis Pipeline
Here's how these primitives compose into a real system. A SaaS company wants to automatically analyze every enterprise deal that closes and generate an account brief.
Step 1: Trigger fires when deals.status → closed_won with tier=enterprise
Step 2: Orchestrator agent runs, reads the deal record, then fans out:
# Orchestrator runs on deal closed_won trigger
deal = adl_get_record(entity_type="deals", entity_id=trigger_entity_id)
results = adl_run_agents(
tasks=[
{
"agent_id": "crm-analyst",
"prompt": f"Pull full contact and company history for deal {deal.entity_id}",
"context": {"deal_id": deal.entity_id, "company_id": deal.data["company_id"]}
},
{
"agent_id": "revenue-analyst",
"prompt": f"Update ARR forecast for Q2 given deal {deal.entity_id} closed at ${deal.data['arr']}",
"context": {"deal_id": deal.entity_id}
}
],
wait=True,
timeout_seconds=180
)
# Write consolidated brief
adl_upsert_record(
entity_type="account_briefs",
entity_id=f"brief_{deal.entity_id}",
data={
"deal_id": deal.entity_id,
"company": deal.data["company"],
"arr": deal.data["arr"],
"crm_summary": results[0]["output"],
"forecast_impact": results[1]["output"],
"generated_at": "2026-05-23T22:00:00Z"
}
)
# Notify account team
adl_send_message(
recipient_agent_id="account-executive",
message_type="finding",
body={
"entity_type": "account_briefs",
"entity_id": f"brief_{deal.entity_id}",
"summary": f"Account brief ready for {deal.data['company']}"
}
)
Step 3: The account brief entity is now queryable by any agent or human in the workspace.
Memory Zones and Tool Discipline
Two operational rules that prevent the most common agentic failures:
Memory Zones
| Zone | Namespace prefix | Access |
|---|---|---|
| North Star | northstar:* | Read-only — workspace config, brand voice, product catalog |
| Shared | shared:* | Read before overwrite — cross-agent state |
| Private | plain namespaces | Your agent's own state |
Never write to northstar:*. It's workspace-wide configuration. Violations produce permission errors.
Tool Budget
Each agent run has a target of 3-5 tool calls for scheduled work, hard cap of 8 before wrap-up. This isn't arbitrary — it keeps costs predictable and forces agents to fetch only what they need:
- Use
adl_query_recordswith filters, notlimit=100+ filter in reasoning - Use
adl_get_recordwhen you already have the entity_id - Batch writes with
adl_bulk_upsert(3+ records at once) - Don't re-read data you just wrote
Summary
OpenCLAW gives you the primitives to build production-grade agentic systems without reinventing coordination infrastructure:
- Triggers for event-driven and scheduled starts
- Workflows for branching, multi-step sequences
- A2A messaging for loose coupling between agents
- Sync and parallel delegation for fan-out subtasks
- Shared entity records as the coordination substrate
The result is agents that behave predictably, leave queryable audit trails, and compose cleanly — without the message-queue complexity of building this from scratch.
Ready to build your first agentic workflow? Start with adl_list_triggers to see what's already running, then adl_create_workflow to add your first DAG.