Workflows are GAIA’s most powerful feature—intelligent automation sequences that execute complex multi-step tasks across your connected integrations. Unlike simple scripts, GAIA workflows leverage AI to understand context, make decisions, and adapt to changing situations.
# From: apps/api/app/agents/prompts/workflow_prompts.py:287-356# When executing a workflow, GAIA:# 1. Receives trigger context (if event-driven)# 2. Loads workflow steps# 3. Executes each step with full intelligence# 4. Passes context between steps# 5. Handles errors and retries# 6. Logs execution for learning
Turn any successful interaction into a reusable workflow:
// From: apps/web/src/features/workflows/types/workflowExecutionTypes.ts// After completing a task manually with GAIA:// "Save this as a workflow that runs every Monday"// GAIA extracts:interface ConversationContext { suggested_title: string; summary: string; workflow_steps: string[]; integrations_used: string[];}// And creates a reusable automation
# From: apps/api/app/agents/prompts/workflow_prompts.py:139-180# CRITICAL RULES:# - MINIMIZE STEPS: Aim for 3-5 max# - COMBINE OPERATIONS: Use tools that handle multiple tasks# - ELIMINATE REDUNDANCY: Never duplicate actions# - NO COGNITIVE STEPS: No "analyze" or "review" steps# - ONLY EXTERNAL ACTIONS: Every step must use a tool
Bad Example (Inefficient):
{ "steps": [ {"title": "Fetch email", "category": "gmail"}, {"title": "Read email content", "category": "general"}, {"title": "Analyze sentiment", "category": "general"}, {"title": "Extract action items", "category": "general"}, {"title": "Create todo for each item", "category": "todos"}, {"title": "Log the interaction", "category": "documents"} ]}
Good Example (Optimized):
{ "steps": [ { "title": "Process email and extract actions", "category": "gmail", "description": "Get email content and identify action items" }, { "title": "Create todos in batch", "category": "todos", "description": "Create todo items for all extracted actions" } ]}
The LLM executing the workflow handles all analysis, understanding, and decision-making. Steps should only describe external tool actions.
# From: apps/api/app/agents/prompts/workflow_prompts.py:358-440# Email-triggered workflows receive full context:EMAIL_TRIGGERED_WORKFLOW_PROMPT = """You are executing a workflow triggered by an email.EMAIL CONTEXT AVAILABLE:- From: {email_sender}- Subject: {email_subject}- Content: {email_content_preview}- Received: {trigger_timestamp}You DON'T need to fetch the email—you already have it!Focus on USING the email data, not retrieving it."""
# Agents can discover tools at runtimeretrieve_tools(query="send slack message")# Returns: SLACK_SEND_MESSAGE, SLACK_SEND_DIRECT_MESSAGE, etc.# Then load specific toolsretrieve_tools(exact_tool_names=["SLACK_SEND_MESSAGE"])
# From: apps/api/app/models/workflow_models.py:221-228class Workflow(BaseModel): current_step_index: int execution_logs: List[str] error_message: Optional[str] # Workflows maintain state for recovery # Failed steps can be retried # User notified of failures
# From: apps/api/app/agents/prompts/workflow_prompts.py:330-343# Main agent routes steps to specialized subagents:if step.category in ["gmail", "notion", "twitter", "linkedin", "calendar"]: # Use handoff for provider-specific tools handoff( subagent_id=step.category, task=f"{step.title}: {step.description}" )else: # Direct execution for general tools retrieve_tools(query=step.description) # Call tools directly