Upstash Workflow JS
UpstashOfficialCreated by Upstash
- Skill
- Tool integration
- Cloud and DevOps
- MIT
- Medium risk
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The Upstash Workflow SDK enables developers to create reliable, multi-step workflows within serverless environments. By leveraging QStash, it allows functions to survive timeouts, retries, and restarts, effectively managing long-running processes that span minutes or days without keeping the underlying function execution active. It supports complex orchestration patterns, including step-by-step execution, external API calls, event waiting, human-in-the-loop approvals, and sophisticated flow control.
What it does
- Exposes serverless endpoints for durable workflow execution.
- Manages multi-step processes that persist across function restarts and timeouts.
- Provides tools for flow control, including concurrency, rate limiting, and parallelism.
- Supports advanced patterns like cross-workflow invocation and waiting for external events.
- Enables local development and testing via the QStash dev server.
- Facilitates human-in-the-loop workflows and real-time updates.
When to use it
- When building long-running tasks that exceed standard serverless function execution limits.
- When implementing saga or orchestration patterns in a distributed system.
- When you need reliable background jobs with built-in checkpointing and retries.
- When building AI agents or orchestrators that require stateful, multi-step execution.
- When integrating human approval steps into automated backend processes.
Advantages
- Eliminates the need to hold serverless functions open for long durations.
- Built-in support for retries, failure callbacks, and dead-letter queues.
- Seamless integration with popular serverless platforms like Vercel and Cloudflare Workers.
- Simplifies complex state management for asynchronous operations.
Usage examples
- “How do I define a basic two-step workflow using the Upstash SDK?”
- The agent provides a code snippet using the serve() function and context.run() to define sequential steps that persist across execution.
- “How can I trigger a workflow from my existing backend code?”
- The agent demonstrates initializing the Workflow Client with a QStash token and using the trigger() method to initiate the workflow URL.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/upstash/upstash-workflow-js/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip upstash-workflow-js.zip -d .agents/skills
Documentation by Upstash
Upstash Workflow SDK
Bundled docs and source
Before writing or debugging SDK code, check node_modules/@upstash/workflow/docs/ for bundled docs and node_modules/@upstash/workflow/src/ for readable TypeScript source. Read and search the relevant files when present; otherwise use the references in this skill.
Quick Start
The Upstash Workflow SDK lets you expose serverless workflow endpoints and run them reliably using QStash under the hood.
Install:
npm install @upstash/workflowDefine a simple workflow endpoint:
import { serve } from "@upstash/workflow";
export const { POST } = serve(async (context) => {
await context.run("step-1", () => console.log("step 1"));
await context.run("step-2", () => console.log("step 2"));
});Trigger it from your backend:
import { Client } from "@upstash/workflow";
const client = new Client({ token: process.env.QSTASH_TOKEN! });
await client.trigger({ url: "https://your-app.com/api/workflow" });Other Skill Files
These files contain the full documentation. Use them for details, patterns, and advanced behavior.
basics:
basics/serve – How to expose workflow endpoints.
basics/context – Full API for workflow
context(steps, waits, webhooks, events, invoke, etc.).basics/client – Using the Workflow client to trigger, cancel, inspect, and notify runs.
features:
features/invoke – Cross‑workflow invocation.
features/reliability – Retries, failure callbacks, and DLQ.
features/flow-control – Rate limits, concurrency, and parallelism.
features/wait-for-event – Notify and wait-for-event patterns.
features/webhooks – Webhook creation and consumption.
how to:
how-to/local-dev – Local QStash dev server (auto via
QSTASH_DEV=true) and tunneling.how-to/realtime – Realtime and human‑in‑the‑loop workflows.
how-to/migrations – Migrating workflows safely.
how-to/middleware – Adding middleware to workflows.
other files:
rest-api – Low-level REST endpoints for interacting with QStash/Workflow.
troubleshooting – Common debugging and environment issues.
agents – Using Workflow with agents, orchestrators, and automation patterns.
Files
- ATTRIBUTION.mdAdded by AutoGineer892 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md3.4 KiB
- agents.md6.7 KiB
- basics/client.md4.1 KiB
- basics/context.md5.1 KiB
- basics/serve.md2.4 KiB
- features/flow-control.md3.9 KiB
- features/invoke.md2.6 KiB
- features/retries-failures-reliability.md6.3 KiB
- features/wait-for-event.md2.8 KiB
- features/webhooks.md2.5 KiB
- how-to/local-dev.md5.0 KiB
- how-to/middleware.md4.7 KiB
- how-to/migrations.md4.8 KiB
- how-to/realtime.md4.8 KiB
- rest-api.md6.6 KiB
- troubleshooting.md4.8 KiB
agents.md
name: workflow-agents description: Skill for building, configuring, and orchestrating Upstash Workflow Agents. Use when the user mentions agent workflows, multi-agent collaboration, tools, tasks, Upstash Workflow, or patterns like evaluator-optimizer, prompt chaining, parallelization, or orchestrator-workers.
Workflow Agents
This Skill provides guidance for defining and orchestrating agents, tools, models, and tasks inside Upstash Workflow using TypeScript. It explains core concepts, common patterns, workflow configuration, and pitfalls.
Quick Overview
Use this Skill when:
Building agents with tools and backgrounds
Creating multi-step or multi-agent tasks
Implementing patterns like evaluator-optimizer or prompt chaining
Integrating LangChain or AI SDK tools
Running workflows reliably inside Upstash Workflow
The Workflow Agents API centers around four elements:
Models — LLM providers (OpenAI, Anthropic, or any AI SDK provider)
Tools — Functions agents can call
Agents — LLM instances with background, maxSteps, and tools
Tasks — Executable prompts assigned to one or more agents
Defining Models
A model defines which provider the agent uses and includes optional configuration for retries, timeouts, or rate‑limits.
const agents = agentWorkflow(context);
// Basic OpenAI model
const model = agents.openai("gpt-3.5-turbo");
// OpenAI-compatible provider
const deepseek = agents.openai("deepseek-chat", {
baseURL: "https://api.deepseek.com",
apiKey: process.env.DEEPSEEK_API_KEY,
});
// AI SDK provider (ex: Anthropic)
const anthropic = agents.AISDKModel({
context,
provider: createAnthropic, // imported from @ai-sdk/anthropic
providerParams: { apiKey: process.env.ANTHROPIC_KEY },
agentCallParams: {
timeout: 1000,
retries: 0,
},
});Key parameters:
callSettings / agentCallParams — timeout, retries, flow control
provider / providerParams — when using AI SDK providers
Pitfall: If you use an OpenAI-compatible provider, you must set baseURL.
Defining Tools
Tools extend what agents can do. Workflow supports:
WorkflowTool (native)
AI SDK tools
LangChain tools
Agentic toolkits
import { z } from "zod";
import { tool } from "ai";
import { WorkflowTool } from "@upstash/workflow-agents";
import { WikipediaQueryRun } from "@langchain/community/tools/wikipedia_query_run";
const mathTool = tool({
description: "Evaluate a math expression",
parameters: z.object({ expression: z.string() }),
execute: async ({ expression }) => mathjs.evaluate(expression),
});
const workflowMath = new WorkflowTool({
description: "Evaluate math (workflow step aware)",
schema: z.object({ expression: z.string() }),
invoke: async ({ expression }) => mathjs.evaluate(expression),
executeAsStep: false, // allows context.call, etc.
});
const wikiTool = new WikipediaQueryRun({
topKResults: 1,
maxDocContentLength: 500,
});Common mistakes:
Workflow wraps execute/invoke in
context.runby default, so you cannot use context.call unlessexecuteAsStep: falseis set.LangChain tools must return strings, not objects.
Defining Agents
Agents wrap a model and add behavior via:
maxSteps— how many LLM calls the agent is allowed to makebackground— system prompttools— available actions
const generator = agents.agent({
model,
name: "generator",
maxSteps: 1,
background: "Generate text from prompts.",
tools: {},
});
const evaluator = agents.agent({
model,
name: "evaluator",
maxSteps: 1,
background: "Evaluate responses and give corrections.",
tools: {},
});Tips:
Pick maxSteps carefully; too low prevents tool use; too high increases cost.
Names appear in Upstash Console logs; keep them descriptive.
Tasks (Single & Multi Agent)
A task is a single execution of an agent or a group of agents.
// Single agent task
const single = agents.task({
agent: generator,
prompt: "Explain quantum mechanics.",
});
const { text } = await single.run();
// Multi-agent with manager agent
const multi = agents.task({
model, // manager LLM
agents: [generator, evaluator],
maxSteps: 3,
prompt: "Generate text and refine it until quality improves.",
});
const result = await multi.run();Tip: In multi-agent mode, the model becomes a "manager" system that decides which agent to call.
Common Agent Patterns
Below are the patterns supported by the source files in this skill.
Prompt Chaining
Sequential agent calls where each output becomes the next input. Useful for: stepwise research, multi‑stage content generation, breaking down complex tasks.
Pitfall: watch maxSteps for agents that need both tool calls and summarization.
Evaluator‑Optimizer
Loop until evaluator returns a PASS. Simple feedback‑refinement pattern.
Pitfall: Always check evaluator output with .includes("PASS"), not strict equality.
Parallelization
Use multiple agents with Promise.all and then aggregate.
Pitfall: Avoid extremely large aggregated prompts; summarizing before combining is recommended.
Orchestrator‑Workers
Manager delegates sub‑tasks to specialized workers. Useful for structured Q&A, multi‑topic analysis, or complex synthesis.
Pitfall: The manager must have enough maxSteps to orchestrate multiple workers.
Best Practices
Give each agent a clear background; ambiguous roles cause incorrect tool use.
Define tools with strict schemas so LLMs call them reliably.
Use multi-agent tasks when the problem requires specialization.
Inspect console logs to debug tool calls and agent decisions.
Use local QStash dev server during development to avoid rate limits.
Example: Combined Setup (models + tools + agents + tasks)
This shows all core fields together in one concise example.
export const { POST } = serve(async (context) => {
const agents = agentWorkflow(context);
const model = agents.openai("gpt-4o");
const mathTool = tool({
description: "Compute math",
parameters: z.object({ expression: z.string() }),
execute: async ({ expression }) => mathjs.evaluate(expression),
});
const researcher = agents.agent({
model,
name: "researcher",
maxSteps: 2,
background: "Research topics using wiki.",
tools: { wikiTool },
});
const mathematician = agents.agent({
model,
name: "math",
maxSteps: 2,
background: "Solve numeric problems.",
tools: { mathTool },
});
const task = agents.task({
model, // manager
agents: [researcher, mathematician],
maxSteps: 3,
prompt: "Tell me about 3 stars and compute the sum of their masses.",
});
return (await task.run()).text;
});Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Node.js
Security
What our scanner noticed· Medium risk
- Possible data-exfiltration endpoints
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Upstash
- Publisher
- Upstash (Official)
- Source
- upstash/skills · skills/upstash-workflow-js · commit 9f9e3e5
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Upstash or Upstash.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download upstash-workflow-js.zip