Skip to content

Workflow Building Blocks ​

Each example below is a complete workflow that shows one building block. Copy it into a .yaml file, change the commands, and run it with dagu start <file>. Examples that run a script such as ./load.sh set working_dir: ., so the script sits beside the DAG file; without it, steps start in an empty per-run directory.

ExampleBuilding block
Run steps in parallel, then jointype: graph, depends
Pass typed values between stepsparams, step output
Run on a schedule with retriesschedule, defaults
Run one step in a containerdocker.run
Summarize text with an LLMchat.completion
Run a coding agentharness.run, tools
Collect input from a personhuman.task
Call a reusable sub-workflowdag.run

Run Steps in Parallel, Then Join ​

test and build both wait for checkout, run at the same time, and package waits for both.

yaml
working_dir: .

type: graph
steps:
  - id: checkout
    run: git checkout main

  - id: test
    depends: [checkout]
    run: ./scripts/test

  - id: build
    depends: [checkout]
    run: ./scripts/build

  - id: package
    depends: [test, build]
    run: ./scripts/package

Run graph: checkout fans out to test and build, which join at packageRun graph: checkout fans out to test and build, which join at package

If test or build fails, package does not run. See Control Flow.

Pass Typed Values Between Steps ​

Validate a parameter before the run starts, capture a value from one step, and use both in the next.

yaml
working_dir: .

params:
  - name: ENVIRONMENT
    type: string
    enum: [staging, production]
    default: staging

steps:
  - id: version
    run: git describe --tags --abbrev=0
    output:
      tag:
        from: stdout

  - id: deploy
    run: ./deploy --env '${params.ENVIRONMENT}' --version '${steps.version.outputs.tag}'

A value outside enum is rejected before any step runs. The reference to version also makes deploy wait for it, so no depends entry is needed. See Parameters and Outputs.

Run on a Schedule With Retries ​

Run at 09:00 New York time on weekdays, retry failed steps, and replay runs missed while the scheduler was down.

yaml
working_dir: .

schedule: "CRON_TZ=America/New_York 0 9 * * 1-5"
catchup_window: 4h

defaults:
  retry_policy:
    limit: 2
    interval_sec: 30
  timeout_sec: 900

steps:
  - id: sync_customers
    run: ./sync-customers --incremental

  - id: rebuild_search
    depends: [sync_customers]
    run: ./rebuild-search-index

Every step retries up to 2 times, 30 seconds apart, and is stopped after 15 minutes. Aliases such as @hourly and @daily also work. See Scheduling and Step Defaults.

Run One Step in a Container ​

Give one step its own runtime without containerizing the rest of the workflow.

yaml
working_dir: .

steps:
  - id: test_in_container
    action: docker.run
    with:
      image: python:3.13-slim
      pull: missing
      auto_remove: true
      working_dir: /workspace
      volumes:
        - .:/workspace:ro
      command: python -m pytest -q
    stdout:
      artifact: test-results.txt

working_dir: . makes . the directory that holds the DAG file, which is mounted read-only. The test output is saved as a run artifact. Set DAGU_CONTAINER_RUNTIME=podman on the Dagu server to use Podman. See Docker.

Summarize Text With an LLM ​

Send a step's output to a model and save the answer as an artifact. Needs an OpenRouter API key in OPENROUTER_API_KEY.

yaml
secrets:
  - name: OPENROUTER_API_KEY
    provider: env
    key: OPENROUTER_API_KEY

llm:
  provider: openrouter
  model: deepseek/deepseek-v4-flash

steps:
  - id: collect
    run: tail -n 200 /var/log/app/incidents.log
    output:
      lines:
        from: stdout

  - id: summarize
    action: chat.completion
    with:
      prompt: |
        Summarize these incident log lines in five bullets:
        ${steps.collect.outputs.lines}
    stdout:
      artifact: incident-summary.md

The model's reply is the step's stdout, so it lands in incident-summary.md. See LLM Steps.

Run a Coding Agent ​

Run an agent CLI as a step with retries, logs, and an artifact. Needs an OpenRouter API key in OPENROUTER_API_KEY.

yaml
working_dir: .

tools:
  - anomalyco/opencode@v1.18.11

secrets:
  - name: OPENROUTER_API_KEY
    provider: env
    key: OPENROUTER_API_KEY

steps:
  - id: review
    action: harness.run
    with:
      provider: opencode
      managed: false
      model: openrouter/deepseek/deepseek-v4-flash
      prompt: |
        Review the most recent commit without modifying files.
        Return short Markdown with a summary, risks, and verdict.
    retry_policy:
      limit: 2
      interval_sec: 30
    stdout:
      artifact: ai/repository-review.md

tools installs the pinned OpenCode release before the run, so the host needs nothing preinstalled. managed: false runs that release in the step instead of a managed OpenCode session, which does not read tools or secrets. Other providers include codex, claude, copilot, and pi. See Harness and Tools.

Collect Input From a Person ​

Pause the run for a typed form, then use the answers in later steps.

yaml
params:
  - name: RELEASE
    default: v1.4.0

steps:
  - id: handoff
    action: human.task
    with:
      prompt: Complete the handoff for ${params.RELEASE}
      form:
        type: object
        additionalProperties: false
        properties:
          environment:
            type: string
            enum: [staging, production]
          change_ticket:
            type: string
            pattern: '^CHG-[0-9]+$'
        required: [environment, change_ticket]

  - id: report
    action: template.render
    with:
      template: |
        # Release {{ .release }}
        Environment: {{ .environment }}
        Change: {{ .ticket }}
      data:
        release: ${params.RELEASE}
        environment: ${steps.handoff.outputs.environment}
        ticket: ${steps.handoff.outputs.change_ticket}
    stdout:
      artifact: release-handoff.md

The run waits until someone submits the form in the Web UI or with dagu human-task complete. Each form field becomes an output of handoff. To approve or reject work instead, use an approval gate. See Human Tasks.

Call a Reusable Sub-Workflow ​

Run another workflow as one step. The child gets its own run, logs, and status.

yaml
working_dir: .

type: graph
steps:
  - id: tests
    action: dag.run
    with:
      dag: test-suite
      params:
        PACKAGE: ./internal/runtime

  - id: publish
    depends: [tests]
    run: ./publish-results
---
name: test-suite
type: graph
params:
  - name: PACKAGE
    type: string
    required: true
steps:
  - id: unit
    run: go test '${params.PACKAGE}'

  - id: race
    run: go test -race '${params.PACKAGE}'

The --- separator defines test-suite in the same file. If the child run fails, tests fails and publish does not run. See Sub-DAGs.

Next Steps ​

Dagu is open source under the GNU General Public License v3.0.