Skip to content

Multi-Agent Mini Demo

A CPU-runnable, pure-Python miniature of a Multi-Agent system. It demonstrates agents, a message bus, a shared blackboard, deterministic skill calling, handoff and round-robin coordination, and trace observability — without GPUs or external LLM keys.

Design

The demo is split into small, focused modules:

ModuleResponsibility
message.pyMessage dataclass and MessageType enum
bus.pyMessageBus: pub/sub message delivery
blackboard.pyBlackboard: scoped shared workspace
agent.pyAgent: role, instructions, skill registry, inbox
llm_client.pyMockLLMClient: deterministic, rule-based decisions
skills.pyReusable skills: research, draft, review, finalize, handoff
coordinator.pyCoordinator: handoff and round_robin execution modes
observer.pyObserver: structured event recording and trace rendering
demo.pyEntry script: blog-writing task with a full agent team

Why a deterministic LLM client?

Real multi-agent systems use LLM providers that require API keys, network access, and non-deterministic outputs. The demo uses a rule-based client so that:

  • The code runs on any CPU with zero setup.
  • Tests are deterministic and reproducible.
  • The core concepts (agent roles, handoffs, shared state) remain clear.

In production, replace MockLLMClient with a real LLM client.

Install

bash
cd docs/05-agent/multi-agent/mini-demo
pip install -e ".[dev]"

Run the demo

bash
python -m multi_agent_mini.demo

or, after installing the package:

bash
multi-agent-demo

The demo runs a handoff-mode blog-writing task:

  1. Coordinator hands off to the researcher.
  2. Researcher collects facts and writes them to the blackboard.
  3. Writer produces a structured draft using the facts.
  4. Reviewer adds review comments.
  5. Coordinator finalizes the blog post.

Run tests

bash
pytest tests/ -v

Programmatic usage

python
from multi_agent_mini.agent import Agent
from multi_agent_mini.blackboard import Blackboard
from multi_agent_mini.bus import MessageBus
from multi_agent_mini.coordinator import Coordinator
from multi_agent_mini.llm_client import MockLLMClient
from multi_agent_mini.observer import Observer
from multi_agent_mini.demo import make_team

agents = make_team()
coordinator = Coordinator(
    agents=agents,
    mode="handoff",
    blackboard=Blackboard(),
    bus=MessageBus(),
    observer=Observer(),
    llm_client=MockLLMClient(),
)
result = coordinator.run("Write a short post about multi-agent systems.")
print(result["blackboard"]["final_post"])

Mini demo vs. a real framework

CapabilityMini demoReal framework (e.g., LangGraph, CrewAI, AutoGen)
LLMRule-based mockOpenAI / Anthropic / local models
Message transportIn-memory busMessage queue / gRPC / WebSocket
Shared stateIn-memory blackboardDatabase / vector store
Observabilitystdout traceOpenTelemetry / structured logs
Fault toleranceNone by designRetries, timeouts, circuit breakers

This project is intentionally small: it shows the concepts and control flow so readers can understand how a production multi-agent system behaves before adopting a heavier system.

License

Same as the parent project: CC-BY-SA-4.0.

Released under CC-BY-SA-4.0 License.