What is a Workflow?
A workflow in Agility is a visual automation that connects multiple agents together to perform complex tasks. Think of it as a flowchart where each node is an agent that processes data, and the connections define how data flows between them.Workflow Structure
Every workflow consists of three core components:1. Elements
Elements are the individual nodes in your workflow. Each element represents an agent instance with specific configuration.2. Connections
Connections define the flow of data between elements, creating a directed graph of execution.Connections support one-to-many relationships. A single agent can send its output to multiple downstream agents.
3. Workflow Definition
The complete workflow brings elements and connections together:Execution Model
Workflows execute using a breadth-first traversal algorithm:Execution Flow
- Starting Point: Execution begins from a specified element (the trigger agent)
- Queue Processing: Elements are added to a processing queue
- Sequential Execution: Each agent executes in order, one at a time
- Context Building: Each agent’s output is stored in a shared context
- Data Propagation: Downstream agents access outputs via placeholders
- Cycle Prevention: Already-processed elements are skipped to avoid infinite loops
Output Context
The output context is a key-value store that accumulates data as the workflow executes:Data Flow Between Agents
Agents communicate through placeholder resolution:Placeholder Syntax
Use{{input.fieldName}} to reference outputs from previous agents:
Resolution Process
Placeholders are resolved at execution time:- Pattern Matching: The system finds all
{{input.*}}patterns - Path Resolution: Extracts the field path (e.g.,
input.emailBody) - Value Lookup: Retrieves the value from the output context
- Substitution: Replaces the placeholder with the actual value
Workflow Lifecycle
1. Creation
Workflows start empty and agents are added via the visual builder:2. Configuration
Each agent element is configured with specific settings stored in theagent_configs table:
- Agent type (text_generator, gmail_reader, etc.)
- Element ID (unique instance identifier)
- Configuration object (API keys, prompts, etc.)
3. Execution
Workflows execute via therun-workflow function:
4. Result Collection
Execution returns an array of results for each agent:Best Practices
Design Linear Workflows First
Design Linear Workflows First
Start with simple linear chains (A → B → C) before creating complex branching workflows. This makes debugging easier.
Use Descriptive Element Names
Use Descriptive Element Names
Rename elements to describe their purpose (e.g., “Email Summarizer” instead of “Text Generator”).
Test Agent Configurations Individually
Test Agent Configurations Individually
Verify each agent works correctly before connecting them in a workflow.
Monitor Output Context
Monitor Output Context
Understand what data each agent produces to write effective placeholders in downstream agents.
Avoid Circular Dependencies
Avoid Circular Dependencies
While the execution engine prevents infinite loops, circular connections can cause unexpected behavior.
Common Patterns
Trigger → Process → Action
The most common workflow pattern:- Trigger: Reads incoming data (email, GitHub push, etc.)
- Process: Transforms or analyzes the data (summarize, generate response)
- Action: Sends the result somewhere (email, Discord, etc.)
Fan-Out Pattern
One agent sends output to multiple downstream agents:Sequential Processing
Multiple processing steps in series:Technical Details
Storage
Workflows are stored in theuser_workflows table:
id: Workflow UUIDuser_id: Owner’s user IDdata: JSON object containing elements and connectionscreated_at,updated_at: Timestamps
Element ID Format
Element IDs typically include the workflow UUID:{workflow-uuid}-{element-identifier}
This allows the execution engine to determine which workflow an element belongs to.
Connection Map
During execution, connections are transformed into a lookup map:Next Steps
Agents
Learn about the different agent types and how to configure them
Connections
Deep dive into how agents connect and share data