Tenzro
Tutorial — Agents

Build an agent swarm orchestrator

SwarmManager spins up an ephemeral group of member agents under an orchestrator, fans out tasks via the orchestrator's send-message channel, and tracks per-member status. Swarm state is persisted under CF_AGENTS so it survives node restarts.
Level
Advanced
Time
~30 min
Prerequisites
Orchestrator agent registered
Stack
TypeScript · JSON-RPC
01

Create a swarm under an orchestrator

The orchestrator agent ID and the member specs (name + capabilities) define the swarm.

import { TenzroClient } from "tenzro-sdk";
const client = new TenzroClient({ endpoint: "https://rpc.tenzro.network" });

const swarm = await client.agent.createSwarm(
  orchestratorId,
  [
    { name: "reviewer-1", capabilities: ["code"] },
    { name: "reviewer-2", capabilities: ["code"] },
    { name: "reviewer-3", capabilities: ["code"] },
  ],
  { parallel: true, task_timeout_secs: 60 },
);
02

Dispatch work through the orchestrator

Tasks fan out via the orchestrator's send-message channel — each member runs in parallel and the orchestrator records replies.

await client.agent.sendMessage(
  orchestratorId,
  "swarm-broadcast",
  { task: { skill: "code-review", input: { repo: "...", pr: 42 } } },
);
03

Poll swarm status

Status returns the per-member state and completion counters.

const status = await client.agent.getSwarmStatus(swarm.swarm_id);
console.log("members:", status.members.length, "completed:", status.completed);
04

Terminate the swarm

Termination releases per-swarm state; the orchestrator and members remain registered.

await client.agent.terminateSwarm(swarm.swarm_id);
Related
← All tutorials