open-multi-agent/examples
JackChen ffec13e915
refactor: reorganize examples by category (#125)
Examples grew to 19 flat files mixing basics, provider demos, orchestration
patterns, and integrations, with two files colliding on the number 16.
Reorganized into category folders so the structure scales as new providers
and patterns get added.

Layout:
  examples/basics/         core execution modes (4 files)
  examples/providers/      one example per supported model provider (8 files)
  examples/patterns/       reusable orchestration patterns (6 files)
  examples/integrations/   MCP, observability, AI SDK (3 entries)
  examples/production/     placeholder for end-to-end use cases

Notable changes:
- Dropped numeric prefixes; folder + filename now signal category and intent.
- Rewrote former smoke-test scripts (copilot, gemini) into proper three-agent
  team examples matching the deepseek/grok/minimax/groq template. Adapter
  unit tests in tests/ already cover correctness, so this only improves
  documentation quality.
- Added examples/README.md as the categorized index plus maintenance rules
  for new submissions.
- Added examples/production/README.md with acceptance criteria for the new
  production category.
- Updated all internal npx tsx paths and import paths (../src/ to ../../src/).
- Updated README.md and README_zh.md links.
- Fixed stale cd paths inside examples/integrations/with-vercel-ai-sdk/README.md.
2026-04-19 17:01:58 +08:00
..
basics refactor: reorganize examples by category (#125) 2026-04-19 17:01:58 +08:00
integrations refactor: reorganize examples by category (#125) 2026-04-19 17:01:58 +08:00
patterns refactor: reorganize examples by category (#125) 2026-04-19 17:01:58 +08:00
production refactor: reorganize examples by category (#125) 2026-04-19 17:01:58 +08:00
providers refactor: reorganize examples by category (#125) 2026-04-19 17:01:58 +08:00
README.md refactor: reorganize examples by category (#125) 2026-04-19 17:01:58 +08:00

README.md

Examples

Runnable scripts demonstrating open-multi-agent. Organized by category — pick one that matches what you're trying to do.

All scripts run with npx tsx examples/<category>/<name>.ts and require the corresponding API key in your environment.


basics — start here

The four core execution modes. Read these first.

Example What it shows
basics/single-agent One agent with bash + file tools, then streaming via the Agent class.
basics/team-collaboration runTeam() coordinator pattern — goal in, results out.
basics/task-pipeline runTasks() with explicit task DAG and dependencies.
basics/multi-model-team Different models per agent in one team.

providers — model & adapter examples

One example per supported provider. All follow the same three-agent (architect / developer / reviewer) shape so they're easy to compare.

Example Provider Env var
providers/ollama Ollama (local) + Claude ANTHROPIC_API_KEY
providers/gemma4-local Gemma 4 via Ollama (100% local)
providers/copilot GitHub Copilot (GPT-4o + Claude) GITHUB_TOKEN
providers/grok xAI Grok XAI_API_KEY
providers/gemini Google Gemini GEMINI_API_KEY
providers/minimax MiniMax M2.7 MINIMAX_API_KEY
providers/deepseek DeepSeek Chat DEEPSEEK_API_KEY
providers/groq Groq (OpenAI-compatible) GROQ_API_KEY

patterns — orchestration patterns

Reusable shapes for common multi-agent problems.

Example Pattern
patterns/fan-out-aggregate MapReduce-style fan-out via AgentPool.runParallel().
patterns/structured-output Zod-validated JSON output from an agent.
patterns/task-retry Per-task retry with exponential backoff.
patterns/multi-perspective-code-review Multiple reviewer agents in parallel, then synthesis.
patterns/research-aggregation Multi-source research collated by a synthesis agent.
patterns/agent-handoff Synchronous sub-agent delegation via delegate_to_agent.

integrations — external systems

Hooking the framework up to outside-the-box tooling.

Example Integrates with
integrations/trace-observability onTrace spans for LLM calls, tools, and tasks.
integrations/mcp-github An MCP server's tools exposed to an agent via connectMCPTools().
integrations/with-vercel-ai-sdk/ Next.js app — OMA runTeam() + AI SDK useChat streaming.

production — real-world use cases

End-to-end examples wired to real workflows. Higher bar than the categories above. See production/README.md for the acceptance criteria and how to contribute.


Adding a new example

You're adding… Goes in… Filename
A new model provider providers/ <provider-name>.ts (lowercase, hyphenated)
A reusable orchestration pattern patterns/ <pattern-name>.ts
Integration with an outside system (MCP server, observability backend, framework, app) integrations/ <system>.ts or <system>/ for multi-file
A real-world end-to-end use case production/ <use-case>/ directory with its own README

Conventions:

  • No numeric prefixes. Folders signal category; reading order is set by this README.
  • File header docstring with one-line title, Run: block, and prerequisites.
  • Imports should resolve as from '../../src/index.js' (one level deeper than the old flat layout).
  • Match the provider template when adding a provider: three-agent team (architect / developer / reviewer) building a small REST API. Keeps comparisons honest.
  • Add a row to the table in this file for the corresponding category.