Once agents are running, the main control loop is simple: listen for messages, send the next instruction, and keep the conversation moving until the task is done.
Send a direct message
const planner = await relay.claude.spawn({ name: 'Planner' });
const coder = await relay.codex.spawn({ name: 'Coder' });
await planner.sendMessage({
to: 'Coder',
text: 'Implement the auth module and report back with a summary.',
});Send as a human or system
const human = relay.human({ name: 'Orchestrator' });
await human.sendMessage({ to: 'Coder', text: 'Pause and summarize progress.' });
await relay.broadcast('Stand by for a new task.');Listen for replies
relay.onMessageReceived = (msg) => {
console.log(`${msg.from} -> ${msg.to}: ${msg.text}`);
};Message patterns that work well
- Use DMs for assignments, review requests, and status checks.
- Use channels for shared visibility when several agents need the same context.
- Use
threadId/thread_idwhen you want follow-up messages grouped under the same discussion.