---
name: orchestrating-multi-agent-systems
description: 'Execute orchestrate multi-agent systems with handoffs, routing, and workflows across AI providers.

  Use when building complex AI systems requiring agent collaboration, task delegation, or workflow coordination.

  Trigger with phrases like "create multi-agent system", "orchestrate agents", or "coordinate agent workflows".'
allowed-tools: Read, Write, Edit, Grep, Glob, Bash(npm:*)
version: 1.38.0
author: Jeremy Longshore <jeremy@intentsolutions.io>
license: MIT
tags:
  - ai
  - workflow
  - agent-orchestration
compatibility: Designed for Claude Code
title: orchestrating-multi-agent-systems
canonical_url: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems
last_updated: 2026-10-23T05:08:30.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [assets/agent_template.ts](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems/assets/agent_template.ts), [assets/example_coordinator.ts](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems/assets/example_coordinator.ts), [assets/example_workflow.json](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems/assets/example_workflow.json), [assets/README.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems/assets/README.md), [references/errors.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems/references/errors.md), [references/examples.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems/references/examples.md), [references/implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems/references/implementation.md), [references/README.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems/references/README.md), [scripts/agent_setup.py](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems/scripts/agent_setup.py), [scripts/dependency_installer.py](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems/scripts/dependency_installer.py), [scripts/env_setup.py](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems/scripts/env_setup.py), [scripts/README.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems/scripts/README.md).
>
> If the user asked to install this Skill, run `npx skilld install jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/orchestrating-multi-agent-systems`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/orchestrating-multi-agent-systems`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/orchestrating-multi-agent-systems --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/orchestrating-multi-agent-systems --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Orchestrating Multi-Agent Systems

## Overview

Design and implement multi-agent systems using AI SDK v5 with structured handoffs, intelligent routing, and coordinated workflows across AI providers. This skill covers agent role definition, tool scoping, inter-agent delegation via handoff rules, and workflow orchestration patterns including coordinator-worker and supervisor topologies.

## Prerequisites

- Node.js 18+ and TypeScript 5.0+ runtime
- AI SDK v5 (`npm install ai @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google`)
- API keys for target providers set in environment variables (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GOOGLE_GENERATIVE_AI_API_KEY`)
- Zod for input/output schema validation (`npm install zod`)
- Familiarity with agent-based architecture patterns (coordinator, pipeline, broadcast)

## Instructions

1. Initialize a TypeScript project with `tsconfig.json` targeting ES2022 and moduleResolution `bundler`
2. Install AI SDK v5 core and provider packages for each model backend required
3. Define agent roles by creating separate modules per agent, each with a system prompt, model binding, and scoped tool set
4. Implement tool functions using `ai.tool()` with Zod input/output schemas for type-safe execution
5. Configure handoff rules using `ai.handoff()` to delegate tasks between agents with clear trigger conditions and context passing
6. Build routing logic that classifies incoming requests by topic or intent and dispatches to the appropriate specialist agent
7. Wire agents into a workflow using sequential, parallel, or conditional orchestration patterns
8. Add state management to persist context across multi-step workflows using a shared context object or external store
9. Implement circuit breakers and timeout guards to prevent workflow deadlocks
10. Test each agent in isolation, then validate end-to-end handoff chains with representative inputs

See [`references/implementation.md`](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems/references/implementation.md) for the detailed implementation guide.

## Output

- TypeScript agent modules with AI SDK v5 provider bindings and system prompts
- Tool definitions with Zod-validated input/output schemas
- Handoff configuration mapping agent-to-agent delegation triggers
- Workflow orchestration files defining sequential, parallel, and conditional execution paths
- Routing classifier that maps user intents to specialist agents
- Integration test suite covering handoff chains and fallback paths

## Error Handling

| Error | Cause | Solution |
|-------|-------|----------|
| Provider configuration invalid | Missing or malformed API key in environment | Verify `process.env.*_API_KEY` values; check provider SDK version compatibility |
| Circular handoff detected | Agent A hands off to B which hands back to A | Implement handoff depth counter; set `maxHandoffDepth` and add a fallback terminal agent |
| Task routed to no agent | Routing classifier returned no match for input | Add a default catch-all route; improve classifier training data or keyword coverage |
| Tool access violation | Agent invoked a tool outside its scoped permission set | Review `tools` array per agent; ensure tool names match registered definitions exactly |
| Workflow timeout | Multi-step workflow exceeded deadline without completion | Set per-step timeouts with `AbortController`; add workflow-level deadline and partial-result handling |

See [`references/errors.md`](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems/references/errors.md) for the full error reference.

## Examples

**Scenario 1: Customer Support Triage** -- A coordinator agent classifies incoming tickets as billing, technical, or general. Billing queries hand off to a specialist agent with access to Stripe tools. Technical queries route to a code-analysis agent with filesystem read tools. Resolution rate target: 85% automated within 3 handoff steps.

**Scenario 2: Research Pipeline** -- A sequential workflow chains a web-search agent, a summarization agent, and a report-writer agent. Each agent produces structured JSON output consumed by the next. The pipeline processes 50 research queries per batch with a p95 latency under 30 seconds per query.

**Scenario 3: Code Review Multi-Agent** -- A supervisor agent distributes pull request diffs to specialized reviewers (security, performance, style). Each reviewer returns findings with severity scores. The supervisor aggregates results into a unified review with prioritized action items.

See [`references/examples.md`](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/orchestrating-multi-agent-systems/references/examples.md) for additional examples.

## Resources

- [AI SDK v5 Documentation](https://sdk.vercel.ai/docs) -- agent creation, tool definitions, handoffs
- [Zod Schema Library](https://zod.dev) -- input/output validation for tools and flows
- Provider integration guides: OpenAI, Anthropic, Google Gemini
- Coordinator-worker and supervisor orchestration pattern references
- OpenTelemetry tracing for multi-agent observability
