Skip to main content

What This Example Shows

  • A real production use case: a content moderation graph where edges carry severity and priority tags
  • The shape of edge metadata in the Graph Workflow request payload
  • How to encode severity (low/medium/high/critical), routing target, and audit labels at the edge level
  • Why the API doesn’t echo metadata back in the response, and how to correlate it client-side so downstream systems can still read it
  • Concrete ops patterns — log filters, SLO grouping, audit queries — that the metadata enables
The Graph Workflow endpoint (POST /v1/graph-workflow/completions) is a premium-only feature available on Pro, Ultra, and Premium plans. Free-tier keys receive a 403. Upgrade your account to run production DAGs.

Why This Matters

Content moderation is a routing problem masquerading as a classification problem. A post comes in, a classifier labels it, and the label has to get to the right place — critical to on-call humans inside an SLA, medium to a review queue, low to passive logging — each with different retry policies, audit requirements, and downstream tooling. When this routing logic lives inside agent prompts, it’s invisible to ops; when it lives in glue code, it’s not auditable. Edge metadata moves the routing semantics to where they belong: the edges of the DAG. Once ops can read severity: "critical" straight off the edge, dashboards group correctly, audit queries become one-liners, and the agents stay focused on the classification job. This tutorial shows the pattern in a content moderation DAG and then shows how downstream systems consume that metadata by correlating it, client-side, against the response.

Step 1: Setup

Step 2: Sketch the Moderation DAG

A single classifier fans out to three downstream routes, each handling a different severity tier. Each edge carries the routing semantics ops cares about.
Three edges, three different metadata blocks. The classifier itself is metadata-agnostic — it just labels and writes; the metadata on the edges tells the platform and downstream tools how each label should be handled.

Step 3: Define the Agents

Step 4: Attach Severity and Routing Metadata to Edges

This is the load-bearing step. Each edge from the classifier into a downstream route gets a metadata block that encodes severity, priority, target queue, SLA budget, and audit label. The keys you pick become the keys your dashboards and audit scripts filter on, so standardize them across your team.
Three edges from the same source, each with different metadata, is the canonical pattern for moderation routing. The classifier doesn’t need to know about severity routing — every downstream node receives its label and the platform knows which edge it crossed and what tags that edge carried.
The standard metadata fields production moderation teams converge on:

Step 5: Submit the Workflow

Step 6: How the Metadata Flows Through the Response

The /v1/graph-workflow/completions response (outputs keyed by agent_name, plus a flat usage object) does not echo edge metadata back to you — the API only returns per-node outputs and aggregate token usage, not a per-edge breakdown. The correlation has to happen client-side: since you already have the edges list you submitted, build a local index from it and join that against the outputs you get back. A downstream system reading the response typically does this:
The API doesn’t return edge metadata in the response — you correlate against the same edges list you already built and submitted (as edge_index does above). Treat the metadata block as a forward contract between your request payload and your moderation infrastructure, not as something the platform hands back to you.

Step 7: Critical-Severity Escalation — Read the Tagged Output

For the on-call path specifically, you want to fast-path the metadata-tagged record into your pager:
The on-call human gets the severity, the SLA budget, and a job ID they can replay if they need to see the full graph context — all from fields that originated on a single edge.

How Ops Teams Actually Use This

Three concrete patterns once metadata is on every edge: Pattern 1 — Audit grep. Compliance asks “show me every moderation decision tagged trust_and_safety in the last 7 days.” With audit_tag on the edges that cross the regulated boundary, this becomes a one-line log query rather than a substring search across prompts. Pattern 2 — SLO grouping. Dashboards group p95 latency by priority (p0, p2, p4). You instantly see which on-call paths are missing their 15-minute SLA and which p4 paths can absorb slowdowns without paging anyone. Pattern 3 — Retry budget enforcement. Edges tagged retry_on_failure: true are the ones that should be retried. When the retry budget for the day is consumed, you can selectively disable retries on priority: "p4" edges while keeping them on p0 ones — a one-line config change rather than a code deploy.

When Downstream Agents Should Inspect Upstream Metadata

The standard case is the one above: metadata is for ops and downstream systems, not the agent. There is one situation where the agent itself should read it: when a single downstream node receives edges from heterogeneous upstreams and needs to branch on which one fired. For that case, include the metadata in the prompt template you assemble before submission:
Most production DAGs do not need this — they get more mileage from the dashboard side of metadata than the prompt side.

Putting It All Together

Next Steps