Real, runnable SwarmAI workflows with detailed architecture diagrams. Clone the repo and run any example in under 5 minutes.
Hierarchical multi-agent research. A program manager coordinates 4 specialists — market intelligence, research, strategy, and writing — to produce a comprehensive competitive landscape report.
Program Manager ├──► Market Intelligence Analyst ├──► Research Analyst ├──► Strategy Consultant └──► Executive Writer ──► Report
Parallel due diligence across financial, market, and legal dimensions. Specialist agents analyze a company simultaneously, then a director synthesizes findings into a comprehensive assessment.
┌─ Financial Analyst ─┐ ├─ Market Analyst ─┤──► Program Director ──► Report └─ Legal & Regulatory ─┘
Manager agent creates an execution plan, delegates search tasks to specialists, collects results, and orchestrates the final report. Workers are selected based on task requirements and tool availability.
Manager ──► Plan ├──► Web Searcher ──► raw data ├──► Data Analyst ──► insights ├──► Fact Checker ──► verified └──► Report Writer ──► final report
The analyst executes tasks while the reviewer evaluates output quality. When capability gaps are detected, new Groovy-based skills are generated, validated in a sandbox, and hot-loaded into the agent mid-run. RL policy decides when to converge.
Analyst ──► Output ──► Reviewer ▲ │ │ ┌─ CAPABILITY_GAP ◄─┘ │ ▼ │ Generate Skill ──► Validate ──► Register └──────────── Retry with new skill
Transparent self-evolution: the swarm discovers a better architecture and applies it automatically on the next run. Configured as SEQUENTIAL, Swarm.kickoff() reads evolution history from H2 and transparently switches to PARALLEL — zero code changes needed.
Run 1: [Tech] ──► [Market] ──► [Risk] (SEQUENTIAL) └── observes: PROCESS_SUITABILITY └── persists: PROCESS_TYPE_CHANGE → H2 Run 2: Swarm.kickoff() reads H2 ┌─ [Tech] ─┐ ├─ [Market] ─┤ (PARALLEL — evolved!) └─ [Risk] ─┘
Production-grade workflow with multi-tenancy (tenant-scoped memory/quotas), budget tracking ($5 cap, 500K token limit), and human-in-the-loop approval gates between research and writing phases.
Tenant: acme-research | Budget: $5.00 / 500K tokens
Research Analyst ──► [APPROVAL GATE] ──► Report Writer
│ auto-approve │
│ after 5s │
└─────────────────┘
──► Budget Snapshot loggedDistributed fan-out pattern. Discovery phase identifies competitor targets, then parallel agents research each target independently. A coordinator synthesizes all findings into a master report.
Discovery ──► [Target A, Target B, Target C] ├──► Research Agent (A) ──┐ ├──► Research Agent (B) ──┤──► Coordinator ──► Master Report └──► Research Agent (C) ──┘
Execute-review-refine loop. The analyst researches, the memo author drafts, and the managing director reviews against a 7-point rubric. Iterates until approved or max iterations reached.
Research Analyst ──► Memo Author ──► Managing Director ▲ │ │ NEEDS_REFINEMENT ◄─────────────┘ (with feedback) │ │ └────────────────┘ APPROVED ──► Final Memo
30+ YAML workflow definitions covering every process type, budget tracking, governance gates, tool hooks, conditional tasks, graph workflows with state channels, and composite pipelines. Zero Java code required.
YAML File ──► YamlSwarmParser ──► SwarmDefinition
│
▼
SwarmCompiler ──► Live Swarm
│
▼
swarm.kickoff()Graph workflow with conditional routing. Writer produces draft, human reviewer scores it. If score >= 80, proceed to publish. If iteration >= 3, force publish. Otherwise, loop back to editor for refinement.
START ──► Writer ──► Reviewer
│
score >= 80 ├──► END (publish)
iteration >= 3 ├──► END (force)
default └──► Editor ──► Writer (loop)ETL-style pipeline. Collector ingests data from CSV and database tools, analyst performs statistical analysis, and generator produces a formatted report with charts description.
Data Collector ──[csv, database]──► Data Analyst ──[calculator]──► Report Generator ──► output/
Full REST API application with AI-powered chat, intelligent routing via SwarmGraph, conversation history, product catalog, order management, and ticket system. Runs on port 8080 with a web UI.
REST API :8080 ──► Classifier ├── BILLING ──► Billing Agent ──┐ ├── TECHNICAL ──► Tech Agent ──┤──► QA ──► Response ├── ACCOUNT ──► Account Agent ──┤ └── GENERAL ──► General Agent ──┘
Complete RAG application with document ingestion, vector store integration (Chroma), semantic search, and multi-agent Q&A pipeline. Runs as a REST API on port 8080.
POST /ingest ──► Embed & Store POST /ask ──► Retriever ──► (Vector Store) ──► Writer ──► Response
Security assessment pipeline with budget controls and tool permission enforcement. Recon agent uses web scraping (READ_ONLY), vulnerability analyst processes findings, writer generates the assessment report.
Recon Agent ──[web-scrape: READ_ONLY]──► Vuln Analyst ──► Report Writer Budget: $5 / 200K tokens | Permission: READ_ONLY enforced
Swarm-based security testing. Scanner discovers targets, parallel agents assess each target independently, coordinator produces a comprehensive security report.
Scanner ──► [Target 1, Target 2, ...] ├──► Exploit Agent ──┐ ├──► Exploit Agent ──┤──► Security Report └──► Exploit Agent ──┘
The simplest possible SwarmAI setup: one agent, one task, sequential process, no tools. Start here to learn the basics of Agent, Task, and Swarm.
[Summarizer] ──► output
A single agent equipped with the CalculatorTool to perform precise arithmetic. The agent decides when to call the tool based on the task description.
[Math Tutor] ──uses──► (CalculatorTool) ──► output
Two agents in sequence. The researcher gathers information, then the editor refines it. Demonstrates task dependencies where one agent output feeds into the next.
[Researcher] ──► [Editor] ──► output
Three agents in a pipeline sharing context (topic, audience, tone, word count) through the inputs map. Each agent builds on the previous output.
[Outliner] ──► [Drafter] ──► [Polisher] ──► output
└──── shared context ────┘A single agent that reasons across multiple LLM turns with automatic context compaction. The agent autonomously decides when to continue and when analysis is complete.
[Deep Researcher] turn 1 → turn 2 → ... → turn 5 (auto-compact after 4K tokens) ──► output
Reactive multi-turn execution with progress hooks showing incremental output as the agent reasons through the problem.
[Agent] ──► stream chunk 1 ──► chunk 2 ──► ... ──► final output
3 resilience scenarios: tool failure recovery, budget enforcement (HARD_STOP), and timeout handling. Demonstrates how SwarmAI handles failures gracefully.
Scenario 1: Tool failure ──► recovery Scenario 2: Budget exceeded ──► HARD_STOP Scenario 3: Timeout ──► graceful shutdown
Shared InMemoryMemory across agents — save, search, recall, and cross-agent knowledge sharing. Demonstrates persistent context across the workflow.
[Research Agent] ──save──► (Memory) ──recall──► [Analysis Agent]
Same task executed at different temperatures and model variants, with side-by-side comparison of outputs. Useful for prompt engineering and model evaluation.
[Task] ──► Agent (temp=0.1) ──► output A
──► Agent (temp=0.7) ──► output B
──► Compare results3 agents analyze the same topic in English, Spanish, and French simultaneously. A synthesizer produces a cross-cultural report combining all perspectives.
┌─ English Agent ─┐ ├─ Spanish Agent ─┤──► Synthesizer ──► Cross-Cultural Report └─ French Agent ─┘
3 analyst agents research a stock in parallel using web search and SEC filings tools, then an investment advisor synthesizes findings into a recommendation.
┌─ Financial Analyst ──[calculator, web]──┐ ├─ Research Analyst ──[web, sec-filings]──┤──► Investment Advisor ──► Report └─ Filings Analyst ──[web, sec-filings]──┘
Analyze codebase architecture, metrics, and dependencies. Works on any local code directory without external API keys.
[Code Analyst] ──[file-read, directory-read]──► Architecture Report
Research workflow using MCP (Model Context Protocol) tools for web fetch and search. Demonstrates the MCP integration pattern.
[Research Agent] ──[mcp-web-fetch, mcp-web-search]──► Report
3-iteration monitoring with file-based state. Detects trends across runs using persistent state files.
[Monitor] ──► Run 1 ──► Run 2 ──► Run 3
└── file state ──┘ (trend detection)Build 4 graph topologies and generate Mermaid diagrams. No LLM needed — demonstrates the graph API and visualization capabilities.
SwarmGraph.create() ──► topology ──► Mermaid diagram
Generate → evaluate → optimize loop with a quality gate. The evaluator scores output on multiple criteria; if score >= 80, it passes. Otherwise, the optimizer refines and loops back.
Generator ──► Evaluator (score >= 80?) ▲ │ │ NO ◄──────────┘ │ ▼ └── Optimizer YES ──► Final Output
Two agents debate a proposition over 3 rounds, then a judge declares the winner. Demonstrates the peer interaction pattern with structured argumentation.
Proponent ──► Opponent ──► Proponent ──► ... (3 rounds)
▼
[Judge] ──► WinnerAgent output quality evaluation with 5-criterion scoring. Includes JUnit 5 unit tests using mock ChatClient — no LLM needed for testing.
[Agent] ──► output ──► 5-criterion scorer JUnit 5: mock ChatClient ──► verify agent config, hooks, dependencies
Distributed fan-out pattern. Discovery phase identifies competitor targets, then parallel agents research each independently. Coordinator synthesizes into a master report.
Discovery ──► [Target A, Target B, Target C] ├──► Research Agent (A) ──┐ ├──► Research Agent (B) ──┤──► Coordinator ──► Master Report └──► Research Agent (C) ──┘
Multi-company investment analysis with parallel agents and cross-agent skill sharing. Each company is analyzed independently, then findings are synthesized.
┌─ Company A Agent ──┐ ├─ Company B Agent ──┤──► Coordinator ──► Investment Report └─ Company C Agent ──┘
Enterprise-grade workflow with SPI extension points (AuditSink, LicenseProvider, MeteringSink), multi-tenancy isolation, and human-in-the-loop approval gates.
[Researcher] ──► [Approval Gate] ──► [Writer]
│ │
+── AuditSink ─── MeteringSink ──────+
+── TenantContext ── BudgetTracker ──+Research pipeline with full observability. Every tool call is audited and sanitized, the entire workflow is recorded for replay. Multi-turn reasoning with auto-compaction.
[Researcher] ──[audit + sanitize + rate-limit]──► output
└── Decision Tracing ── Event Replay ── Structured LoggingMulti-stage composite pipeline: Parallel research → Hierarchical synthesis → Iterative review. Checkpoints between stages, budget enforcement, and Mermaid diagram generation.
[Parallel Research] ──► checkpoint ──► [Hierarchical Synthesis]
──► checkpoint ──► [Iterative Review] ──► Final ReportRAG workflow with vector store search and multi-agent evidence-grounded report writing using InMemoryKnowledge and SemanticSearchTool.
[Retriever] ──(Vector Store)──► [Writer] ──► Grounded Report
Iterative workflow powered by a Deep Q-Network (DQN) policy engine. The RL agent learns optimal strategies for task execution through experience replay and neural network optimization.
Analyst ──► Reviewer ──► DQN Policy ▲ │ └── optimize strategy ────┘
git clone https://github.com/intelliswarm-ai/swarm-ai-examples.git
cd swarm-ai-examples
# Run any example (auto-detects Ollama, builds, and runs)
./run.sh bare-minimum
./run.sh customer-support "I need help with billing"
./run.sh stock-analysis TSLA
# Or run from each example's directory
./customer-support-rest-api/run.sh
./rag-knowledge-base-rest-api/run.sh