Skip to content
GitHub Get Started
Orchestration

Multiplayer

Connect multiple clients to the same agentOS actor so all subscribers receive broadcasted session output, process logs, and shell data, enabling collaborative patterns where one user prompts and others observe.

All clients connected to the same actor receive broadcasted events. This enables building collaborative UIs where multiple users watch an agent work.

client.ts
import { createClient } from "@rivet-dev/agentos/client";
import type { registry } from "./server";
// Client A: creates the session and sends prompts
const clientA = createClient<typeof registry>({ endpoint: "http://localhost:6420" });
const agentA = clientA.vm.getOrCreate("shared-agent");
const connA = agentA.connect();
connA.on("sessionEvent", (data) => {
console.log("[A]", data.event.method);
});
const session = await agentA.createSession("pi", {
env: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY! },
});
await agentA.sendPrompt(session.sessionId, "Build a REST API");
// Client B: observes the same session (in a separate process)
const clientB = createClient<typeof registry>({ endpoint: "http://localhost:6420" });
const connB = clientB.vm.getOrCreate("shared-agent").connect();
connB.on("sessionEvent", (data) => {
console.log("[B]", data.event.method);
});
// Client B sees the same events as Client A

See Full Example