workflow

Instructions for building durable multi-step workflows in a Convex application. Convex is a backend platform, and the workflow component runs stages in order while retrying failed stages independently.

In plain words
What is it for?
Use it for pipelines, ETL—extracting, transforming, and loading data—and other processes where several steps must run in order and each step may need retries.
Why use it?
It keeps pipelines working through crashes and temporary failures, while preserving per-step retries and backoff instead of requiring a hand-built jobs system.

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/get-convex/convex-agent-plugins/workflow
Clone the repo
git clone --depth 1 https://github.com/get-convex/convex-agent-plugins
Per session 20 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 878 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.00020 $0.00878
Opus 5 $0.00010 $0.00439
Sonnet 5 $0.00004 $0.00176
Haiku 4.5 $0.00002 $0.00088

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

Security

Grade A, and why

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.

commands/workflow.md · 67 lines

How it starts

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

Durable multi-step workflows → @convex-dev/workflow

When the task is "do step A, then B, then C, and retry each step independently if it fails" — a pipeline, ETL, or orchestration that must survive crashes — use the workflow component. Do NOT hand-roll it with a jobs table + chained ctx.scheduler.runAfter calls: that reinvents durability, loses per-step retry/backoff, and (measured) scores worse than a plain implementation. Copy this pattern.

Wire the component

// convex/convex.config.ts
import { defineApp } from "convex/server";
import workflow from "@convex-dev/workflow/convex.config";
const app = defineApp();
app.use(workflow);
export default app;

Define the workflow — one step.run* call per stage, retried independently

// convex/workflows.ts
import { WorkflowManager } from "@convex-dev/workflow";
import { components, internal } from "./_generated/api";
import { v } from "convex/values";

export const workflow = new WorkflowManager(components.workflow, {
  // Per-step default: retry each failed step independently with backoff.
  defaultRetryBehavior: { maxAttempts: 4, initialBackoffMs: 1000, base: 2 },
  retryActionsByDefault: true,
});

export const transcribeAndSummarize = workflow.define({
  args: { url: v.string(), userEmail: v.string() },
  handler: async (step, args): Promise<void> => {
    // Each step.runAction is durable + independently retried. If summarize fails
    // 3× then succeeds, transcribe is NOT re-run — completed steps are memoized.
    const transcript = await step.runAction(internal.youtube.transcribe, { url: args.url });
    const summary = await step.runAction(internal.llm.summarize, { transcript });
    await step.runAction(internal.email.sendSummary, { to: args.userEmail, summary });
  },
});
  • The handler's first arg is step, not ctx. Call step.runAction / step.runMutation / step.runQuery with a codegen'd internal.* reference — never ctx.run* inside a workflow (that breaks durability/memoization).
  • Each step.run* is a durable checkpoint. On crash or retry, completed steps are replayed from their stored result, not re-executed — so steps must target internalAction/internalMutations that do the real work.
  • Override retry per step when one stage is flakier: step.runAction(ref, args, { retry: { maxAttempts: 6, initialBackoffMs: 500, base: 2 } }). Set { retry: false } for a step that must not repeat (already-idempotent external charge).
  • The actual work (the YouTube fetch, the LLM call, the email send) lives in ordinary internalActions — external APIs go in actions (see convex-external-apis), email via @convex-dev/resend (see crons).

Read the full file on GitHub · 67 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 · 67 lines · 20 tokens per session scan A d444a1080aec

Subscribe to this mod's changes

workflow is a command published in the GitHub repository get-convex/convex-agent-plugins (112 stars, last pushed 4d ago), licensed MIT. It adds 20 tokens to every session and 878 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.