sequential-workflow

A command pattern for creating a step-by-step pipeline of AG2 agents, software agents built with the AG2 framework. Each stage receives the previous stage's result and passes its own result onward.

In plain words
What is it for?
Use it for workflows such as extracting data, transforming or validating it, and producing a report. You can choose which stages use tools and whether the pipeline stops or continues after an error.
Why use it?
It separates a complex task into clear stages and makes each stage's input, output, and failure behavior explicit.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/davepoon/buildwithclaude/sequential-workflow
Clone the repo
git clone --depth 1 https://github.com/davepoon/buildwithclaude
Per session 16 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 736 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00016 $0.00736
Opus 5 $0.00008 $0.00368
Sonnet 5 $0.00003 $0.00147
Haiku 4.5 $0.00002 $0.00074

Measured 2d ago against content hash 865e1d9a2005, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

sequential-workflow scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/ag2-agent-builder/commands/sequential-workflow.md · 117 lines

How it starts

The opening of the file, as written. The whole thing — 117 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are creating a sequential AG2 agent pipeline. Each agent processes output from the previous one.

Instructions

  1. Ask the user for:

    • The pipeline stages and what each does
    • Whether any stage needs tools
    • Input/output format expectations
    • Error handling: stop on failure or continue?
  2. Create the sequential workflow:

Sequential Pipeline Pattern

from autogen import ConversableAgent

# --- Define Pipeline Stages ---

stage_1 = ConversableAgent(
    name="Extractor",
    description="Extracts structured data from raw input",
    system_message="""You extract structured data from the input.

Output format: JSON with the extracted fields.
Always output valid JSON. Do not include explanations outside the JSON block.""",
    llm_config={"model": "gpt-4o-mini"},
)

stage_2 = ConversableAgent(
    name="Transformer",
    description="Transforms and enriches extracted data",
    system_message="""You receive extracted data and transform it.

- Normalize formats
- Enrich with derived fields
- Validate completeness

Output format: JSON with transformed data.""",
    llm_config={"model": "gpt-4o-mini"},
)

stage_3 = ConversableAgent(
    name="Reporter",
    description="Generates a human-readable report from processed data",
    system_message="""You receive processed data and create a clear report.

- Summarize key findings
- Highlight anomalies
- Provide actionable recommendations""",
    llm_config={"model": "gpt-4o-mini"},
)

# --- Run Sequential Pipeline ---

# Stage 1: Extract
result_1 = stage_1.initiate_chat(
    stage_2,
    message="Raw input data here...",
    max_turns=1,  # Single exchange per stage
)

# Stage 2 -> Stage 3: Transform and Report
result_2 = stage_2.initiate_chat(
    stage_3,
    message=result_1.summary,  # Pass output forward
    max_turns=1,
)

# Final output
final_report = result_2.summary

Pipeline with Validation Gate

# Add a validation step between stages
validator = ConversableAgent(
    name="Validator",
    description="Validates data quality between pipeline stages",
    system_message="""You validate the data passed to you.

Check for:
- Required fields present
- Data types correct
- Values within expected ranges

If valid, respond with: VALID: <the original data>
If invalid, respond with: INVALID: <description of issues>""",
    llm_config={"model": "gpt-4o-mini"},
)

# Run with validation
result = stage_1.initiate_chat(validator, message=input_data, max_turns=1)

if "VALID:" in result.summary:
    # Continue pipeline
    stage_2.initiate_chat(stage_3, message=result.summary, max_turns=1)
else:
    # Handle validation failure
    print(f"Pipeline stopped: {result.summary}")

Read the full file on GitHub · 117 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 117 lines · 16 tokens per session scan A 865e1d9a2005

Subscribe to this mod's changes

sequential-workflow is a command published in the GitHub repository davepoon/buildwithclaude (3,403 stars, last pushed 2d ago), licensed MIT. It adds 16 tokens to every session and 736 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.