Building a Pipeline

This guide walks through building a three-step content pipeline: a researcher gathers information, a writer drafts an article, and an editor polishes it. You will learn pipeline mode, template expressions, dependsOn ordering, and how to trigger a run.


What you will build

[trigger] → researcher → writer → editor → output

Each step receives the previous step’s output as input. The researcher and writer run sequentially; the editor depends on the writer.


Step 1: Define the roles

In ArkTeam, each role is either an inline agent definition or a reference to an existing ArkAgent. For this example, all three are inline:

apiVersion: arkonis.dev/v1alpha1
kind: ArkTeam
metadata:
  name: content-pipeline
  namespace: my-org
spec:
  roles:
    - name: researcher
      model: llama3.2
      systemPrompt: |
        You are a research specialist. Given a topic, provide a detailed
        summary of key facts, recent developments, and notable perspectives.
        Be thorough and cite specific points.
    - name: writer
      model: llama3.2
      systemPrompt: |
        You are a skilled writer. Transform research notes into a clear,
        engaging article with an introduction, body, and conclusion.
        Target audience: technical professionals.
    - name: editor
      model: llama3.2
      systemPrompt: |
        You are a senior editor. Review the article for clarity, flow,
        and accuracy. Tighten the prose and fix any issues.
        Return the final polished article.

Step 2: Define the pipeline

Add the pipeline section with dependsOn ordering and template expressions:

spec:
  output: ""
  pipeline:
    - role: researcher
      inputs:
        prompt: "Research this topic: "
    - role: writer
      dependsOn: [researcher]
      inputs:
        research: ""
        prompt: "Write an article based on this research."
    - role: editor
      dependsOn: [writer]
      inputs:
        draft: ""
        prompt: "Edit and polish this article."

is injected at trigger time. contains the researcher’s full response text.


Step 3: Add a token budget

Protect against runaway costs:

spec:
  maxTokens: 50000   # hard stop per run

Complete YAML

Save this as content-pipeline.yaml:

apiVersion: arkonis.dev/v1alpha1
kind: ArkTeam
metadata:
  name: content-pipeline
  namespace: my-org
spec:
  output: "{{ .steps.editor.output }}"
  maxTokens: 50000
  roles:
    - name: researcher
      model: llama3.2
      systemPrompt: |
        You are a research specialist. Given a topic, provide a detailed
        summary of key facts, recent developments, and notable perspectives.
    - name: writer
      model: llama3.2
      systemPrompt: |
        You are a skilled writer. Transform research notes into a clear,
        engaging article. Target audience: technical professionals.
    - name: editor
      model: llama3.2
      systemPrompt: |
        You are a senior editor. Review for clarity, flow, and accuracy.
        Return the final polished article.
  pipeline:
    - role: researcher
      inputs:
        prompt: "Research this topic: {{ .input.topic }}"
    - role: writer
      dependsOn: [researcher]
      inputs:
        research: "{{ .steps.researcher.output }}"
        prompt: "Write an article based on this research."
    - role: editor
      dependsOn: [writer]
      inputs:
        draft: "{{ .steps.writer.output }}"
        prompt: "Edit and polish this article."

Step 4: Test locally with ark run

Before deploying to a cluster, validate the pipeline structure:

# Validate DAG without executing
ark validate content-pipeline.yaml

# Run with mock responses (zero tokens, instant)
ark run content-pipeline.yaml --provider mock --watch \
  --input topic="Kubernetes operator patterns"

# Run with a real model
OPENAI_BASE_URL=http://localhost:11434/v1 OPENAI_API_KEY=ollama \
  ark run content-pipeline.yaml --provider openai --watch \
  --input topic="Kubernetes operator patterns"

Step 5: Deploy to a cluster

kubectl create namespace my-org --dry-run=client -o yaml | kubectl apply -f -
kubectl apply -f content-pipeline.yaml
kubectl get arkteam content-pipeline -n my-org

Trigger a run:

ark trigger content-pipeline -n my-org \
  --input '{"topic": "Kubernetes operator patterns"}'

Watch status:

kubectl get arkteam content-pipeline -n my-org -w

Adding parallel steps

Steps without a shared dependsOn ancestor run in parallel. Add a fact-checker that runs alongside the writer:

pipeline:
  - role: researcher
    inputs:
      prompt: "Research: "
  - role: writer
    dependsOn: [researcher]
    inputs:
      research: ""
  - role: fact-checker     # runs in parallel with writer
    dependsOn: [researcher]
    inputs:
      claims: ""
  - role: editor
    dependsOn: [writer, fact-checker]   # waits for both
    inputs:
      draft: ""
      corrections: ""

Adding a conditional step

Skip a step based on a previous step’s output:

- role: escalate
  dependsOn: [triage]
  if: ""
  inputs:
    issue: ""

Next steps


Apache 2.0 · ARKONIS