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