Channels: messages between sandboxes
Let sandboxes in your organization send each other messages, hand out work to a pool of workers and collect the results, without giving any sandbox a key.
Sandboxes can't reach each other over the network, so one agent can't quietly poke at another. When you do want them to work together, give them channels: named message lines that belong to your organization. One sandbox sends, others read or take, and you can join in from your own code.
- No keys inside. A sandbox reaches its channels through its own signed door, so there's nothing in it that would work if copied out.
- In order, every time. Each message gets the next number on its channel, so readers see the same order and can pick up where they left off.
- Two ways to read. Every reader can see every message (a log), or each message goes to exactly one worker (a work queue).
- Only the channels you name. A sandbox can use only the channels you gave it when you started it.
- On the record. Sends, reads, takes and refused calls are in the audit log.
How to use it
Check channels are on. They're on for every organization unless an owner or admin turned them off on the Policies page, under Messages between sandboxes.
Start sandboxes with channels. Name the ones each sandbox may use:
channels: ["jobs", "results"], or["*"]for all of them. The sandbox's network must beallowlistoropen; a sandbox with no network access (deny) can't use channels.Inside a sandbox, call
$QR_CHANNELS_URL. No key or header is needed:# send curl -s -X POST "$QR_CHANNELS_URL/jobs/messages" -d '{"body": {"file": "report.py"}}' # read every message after number 0, waiting up to 25 s for new ones curl -s "$QR_CHANNELS_URL/results/messages?after=0&wait=25" # take one job (only you get it), then mark it done curl -s -X POST "$QR_CHANNELS_URL/jobs/take" -d '{"leaseSec": 300, "wait": 25}' curl -s -X POST "$QR_CHANNELS_URL/jobs/messages/1/ack"From your own code or an agent, it's the same. Use your API key on
/api/v1/channels/...(see the API reference), or the hosted MCP toolssend_message,read_messagesandtake_message.
The sections below go through each step in more detail.
Start sandboxes that can talk
Name the channels a sandbox may use when you create it, or ["*"] for every channel in your organization:
import { Sandboxes } from "@quietrobot/sandboxes";
const qr = new Sandboxes();
const workers = await Promise.all([1, 2, 3].map(() => qr.create({ channels: ["jobs", "results"] })));worker = qr.create(channels=["jobs", "results"])qr create --channel jobs --channel resultsA sandbox's network has to allow outbound calls (allowlist or open); in allowlist mode the address it needs is added for you. Inside, QR_CHANNELS_URL holds its door to its channels. A fork keeps the parent's channels with its own door.
Send and read from your code
Your API key can use any channel in your organization:
await qr.channels.send("jobs", { file: "report.py" });
for await (const m of qr.channels.listen("results")) {
console.log(m.seq, m.body);
}A message body is any JSON up to 64 KB. read(name, { after, wait }) returns the messages after a number you've already seen, and waits up to 25 seconds for new ones when there are none yet, so readers hear about a message as soon as it's sent instead of polling. after: "latest" starts from now.
Inside a sandbox: no key needed
Programs in the sandbox use QR_CHANNELS_URL; the clients find it for themselves:
import { Channels } from "@quietrobot/sandboxes";
const ch = Channels.inSandbox();
const job = await ch.take("jobs", { wait: 25, leaseSec: 300 });
if (job) {
await ch.send("results", { done: job.body });
await ch.ack("jobs", job.seq);
}from quietrobot_sandboxes import Channels
ch = Channels.in_sandbox()
job = ch.take("jobs", wait=25, lease_sec=300)qr channels take jobs --lease 300 --wait 25 # exits 3 when there's nothing to take
qr channels send results '{"ok": true}' --json-bodyOr plain HTTP with no headers at all: curl -s -X POST "$QR_CHANNELS_URL/results/messages" -d '{"body":{"ok":true}}'.
A call that doesn't come from that sandbox, such as the address copied to another machine or to another sandbox, is refused and recorded in the audit log.
A log or a work queue
| Notes | read | take and ack |
|---|---|---|
| Who gets a message | Every reader | Exactly one caller |
| Good for | Results, events, a shared chat between agents | Handing jobs to a pool of workers |
| Keeping your place | Pass the last seq you saw as after | The channel keeps track |
| If a worker dies | Nothing to do | With a lease, the job goes back after the lease ends; without one, it's handed out once |
With a lease (5 to 3,600 seconds), ack when the job is done. An ack after the lease has ended is refused, since another worker may have the job by then.
Limits
| Notes | Notes |
|---|---|
| Message size | 64 KB of JSON |
| Channels per organization | 100 |
| Channels per sandbox | 20 named, or every channel with * |
| Messages kept | 7 days, and the newest 10,000 per channel |
| Messages per read | 100 |
| Longest wait | 25 seconds per call; call again to keep waiting |
Deleting a channel (with your API key, never from inside a sandbox) deletes its messages.
Turn channels off
An owner or admin can turn channels off for the whole organization on the Policies page: Messages between sandboxes. While off, new sandboxes can't ask for channels and running ones are refused.
From an agent
The MCP server has list_channels, send_message, read_messages and take_message (pass ackSeq to finish a job), and create_sandbox takes channels. The endpoints are under Channels in the API reference.