WaggleDance

Multi-agent communication protocol -- how Waggle OS agents coordinate, share knowledge, and solve problems together.

@waggle/waggle-dance
Single-User Multi-Agent
One user, multiple specialist agents working in parallel. The SubagentOrchestrator resolves dependencies, injects context, and synthesizes results into a unified answer.
👤
User
🎯
Orchestrator
🔍
Researcher
💻
Coder
📊
Analyst
1. Decompose
2. Spawn
3. Execute
Merged Result
4. Return
👤
User
Team WaggleDance
Multiple users share a team memory layer via TeamSync. Knowledge discovered by one agent flows to all team members automatically -- push-on-write, pull-on-activate.
👤
User A
🐝
Agent A
Discovers
🧠
Local Mind A
Writes
🏠
Shared Team Memory
Push
Pull
🧠
Local Mind B
🐝
Agent B
👤
User B
Recalls
TeamSync: frameToEntity() -- composite key gopId+t
👤
User C (also synced)
Task Dispatcher
The WaggleDanceDispatcher routes messages by type/subtype combination. task_delegation spawns workers, knowledge_check searches memory, skill_request resolves capabilities.
📋
Task Delegation
Knowledge Check
🔧
Skill Request
🎯
Dispatcher
🔎
Cap. Match
Worker Spawn
🧠
Memory Search
🐝
Agent Pool
🐝
New Worker
📦
Results
Protocol: request=[knowledge_check, task_delegation, skill_request] | response=[knowledge_match, task_claim] | broadcast=[discovery, routed_share, skill_share]
HiveQuery Broadcast
One agent broadcasts a question to the entire hive. Every agent searches its knowledge, and results are collected, ranked by relevance, and the best answer surfaces. Like a hive mind where every bee contributes.
📢
Broadcast Query
HiveQuery { topic, scope }
🐝
Researcher
🐝
Coder
🐝
Analyst
🐝
Writer
🐝
Reviewer
🏆
Collect + Rank
Best Answer
Surfaces
Shared Resources
What flows between agents in the WaggleDance protocol. Every shared resource type maps to a real mechanism in the codebase.
🧠
Memory Frames
Shared via team-sync.ts. Push-on-write, pull-on-activate. Frames carry author attribution (userId + displayName).
team-sync.ts
🎯
Skills
Shared via skill_share broadcast message. Receiving agents install shared skills into their workspace skill library.
dispatcher.ts
🕸
Knowledge Graph
Entity-relation graph with bitemporal validity. Global KG queries span all workspaces via MultiMindCache.
knowledge.ts
🧬
Learnings
Evolution improvements propagate: persona overrides, behavioral-spec patches. Accepted runs improve all agents globally.
evolution-deploy.ts
🛠
Tool Pool
Role-based tool presets shared across agents. 8 roles with curated tool sets. filterToolsForContext() enforces access.
subagent-orchestrator.ts
Communication Protocol
The lifecycle of a sub-agent from spawn request to trace recording. Each step maps directly to code in the agent package.
1
Spawn Request
Orchestrator receives a WorkflowStep with role, task, tools, and dependency list. Validates that all dependsOn steps have completed before proceeding.
2
Agent Creation
Worker ID generated via makeWorkerId(). WorkerState initialized as pending. The worker:status event fires so UI can show the planned workflow.
3
Context Injection
setParentContext() injects user identity, workspace info, and behavioral rules. Results from contextFrom steps are prepended as prior context. Role tool presets resolved from ROLE_TOOL_PRESETS.
4
Execution
Status transitions: pending -> running -> done|failed. Agent loop runs with constrained tools and turn budget. Token usage tracked in WorkerState.usage.
5
Result Return
Worker result stored in WorkerState.result. Context map updated for downstream steps. Final aggregation mode: concatenate | last | synthesize.
6
Trace Recording
TraceRecorder captures full execution trace: tokens, tools, latency, model, quality. Traces feed into the evolution pipeline -- enabling closed-loop self-improvement.