Build a Pipeline

This guide walks you through building a complete pipeline workflow: multiple agents working together to process work automatically. By the end, you'll have a working support ticket triage pipeline.

What is a Pipeline?

A pipeline chains multiple agents together, where each agent handles one step. Data flows from input through each agent to output:

Input → @triager → @router → @responder → Output ↘ @escalator (for critical items)

Pipelines are ideal when:

Prerequisites

Step 1: Design Your Pipeline

We'll build a support ticket triage pipeline with four agents:

Step 2: Create the Triager Agent

ayo agents create @triager

Edit the system prompt at ~/.config/ayo/agents/@triager/system.md:

# Triager Agent You categorize incoming items by urgency level. ## Urgency Levels - **critical**: System down, security breach, data loss risk - **high**: Customer blocking issue, needs same-day resolution - **normal**: Standard request, 1-2 day resolution - **low**: Nice to have, can wait ## Output Format Always respond with JSON: ```json { "urgency": "high", "category": "billing", "summary": "Brief description" } ```

Step 3: Create the Router Agent

ayo agents create @router

System prompt for @router:

# Router Agent You route tickets to the appropriate handler based on the triager's output. ## Routing Rules - If urgency is "critical" → route to @escalator - If category is "billing" → route to @billing-agent - If category is "technical" → route to @technical-agent - Otherwise → route to @responder ## Output Format ```json { "handler": "@responder", "reason": "Routine request, normal urgency" } ```

Step 4: Create the Handler Agents

ayo agents create @responder ayo agents create @escalator

Configure each with appropriate system prompts for handling their ticket types.

Step 5: Connect with a Flow

Create the flow definition:

ayo flow new triage-pipeline

Edit ~/.config/ayo/flows/triage-pipeline.yaml:

name: triage-pipeline description: Automated support ticket triage steps: - name: triage agent: "@triager" prompt: "Categorize this ticket: {{.input}}" - name: route agent: "@router" depends_on: [triage] prompt: | Route this ticket: Urgency: {{.steps.triage.output.urgency}} Category: {{.steps.triage.output.category}} - name: respond agent: "@responder" depends_on: [route] condition: "{{.steps.triage.output.urgency}} != 'critical'" prompt: "Handle this ticket: {{.input}}" - name: escalate agent: "@escalator" depends_on: [route] condition: "{{.steps.triage.output.urgency}} == 'critical'" prompt: "URGENT: Handle critical ticket: {{.input}}"

Step 6: Run the Pipeline

Test with a single ticket:

echo "Customer reports payment failed repeatedly" | ayo flow run triage-pipeline

Process a batch:

cat tickets.json | ayo flow run triage-pipeline

Step 7: Monitor Progress

# Check status ayo flow status triage-pipeline # View logs ayo flow logs triage-pipeline # See step outputs ayo flow show triage-pipeline --run latest

Step 8: Schedule Continuous Processing

Run the pipeline automatically every 15 minutes:

ayo trigger create ticket-processor \ --cron "*/15 * * * *" \ --flow triage-pipeline \ --input "$(cat new-tickets.json)"

Troubleshooting

Next Steps