Messaging
A message goes from one machine to another machine of the same project, by name. Think email between colleagues: big, slow, read when the receiver is ready. Messages are not for quick back-and-forth or remote calls; put everything the receiver needs in one message.
space-env send issue-1 --context issue-1 --text "Fix issue 1 on branch issue-1; reply when pushed." --data '{"issue": 1}'
space-env send parent --info "tests green on issue-1"
space-env waiting
space-env receive --context issue-1 --timeout 0The model
- The inbox lives in the region, not in the machine. A message waits there while the receiving machine is suspended, restarts or is restored, until something in that machine receives it.
- Receiving takes the message.
space-env receiveclaims the oldest message that matches and removes it from the inbox once it has printed it; no one else gets it. Ifreceiveis killed before it prints the message, or can’t write it out (its output goes to a pipe whose reader is gone), the message comes back within 30 seconds for the nextreceive. Messages that don’t match the filter (--type,--context) stay for later. - Waiting is cheap.
receive --timeoutwaits up to an hour for a message, without polling. - Two types.
agentmessages carry a request (--text,--data) or a reply (--reply), with a conversation id (--context) that replies copy.infomessages (--info) are status lines that need no answer. Theagenttype follows the A2AMessageshape: a role and a list of parts. Subscriptions bring a third,topic, which only the platform sends (Topics). - The platform sets the envelope. The sender (
from) is the machine the message came from, as the platform knows it; a machine can’t send in another machine’s name. A message from a schedule isfromschedule; one sent withspace sendis fromuser:<email>. The envelope’sfrom_kindtells them apart:vmfor a machine,platformfor everything else. A message sent in a conversation carries itscontext_id(a channel’s, see Reaching out). Forks can’t be namedschedule,operator,ownerorplatform.
QoS: how hard to get the receiver’s attention
--qos says what the message does to a receiver that is busy or suspended:
| QoS | Stored | Resumes a suspended machine |
|---|---|---|
whenever (default) | yes | no |
notify | yes | yes |
urgent | yes | yes |
space-env send issue-1 --qos notify --context issue-1 --text "Review the diff on branch issue-1."
space-env send parent --qos urgent --info "blocked: the build needs a secret I don't have"On an agent’s machine nothing reads the inbox but the agent’s session: it takes each
waiting message and gives it to the agent as its next prompt, a turn of the sender’s, once
the running turn is over (Agents: one machine each). No QoS interrupts a turn.
On any other machine a program reads its messages with space-env receive.
Use whenever for almost everything. notify is for a machine that may be suspended and should act
soon. urgent says it matters most; it resumes the receiver as notify does.
A space-env receive that waits doesn’t keep its machine running: the machine is suspended
when nothing else uses it, and resumes for a notify or urgent message, which the receive
then gets. A whenever message stays until the machine resumes for something else.
What is lost, and when
Nothing is lost silently while it waits, but a message is gone in these cases:
- It was received. Receiving deletes it once
receivehas printed it. If the program that read it crashes after that, before acting on it, it is gone; an agent should note what it received before working on it. - It expired. A message nobody received within 24 hours is erased.
- The receiver was deleted. Its inbox goes with it. What it sent stays until received or expired: a fork’s last reply can be read after the fork is gone.
- It was refused. A send to an unknown machine, with an invalid payload, to a full inbox, or over the rate limit fails at once with an error; nothing is stored.
- A retry after a cut connection. When the connection to the platform drops after a
sendwas made, the error says “temporary; try again” and the message may or may not be stored.receiveis safe to repeat; check (space-env waitingin the receiver, or a reply) before repeating asendthat matters twice. - A resume that fails.
notifyandurgentmessages are stored first; if the resume fails (no capacity, quota) the platform retries it, and the message waits either way. A message resumes its machine once: a machine that ran after it arrived and was suspended again without receiving it isn’t resumed for it again; it finds the message the next time it runs.
Limits
| Payload | 100 KB (the JSON of the parts); link to larger content with a URL |
| Lifetime | 24 hours unclaimed, then the message is erased |
| Receivers | Machines of the same project, by name |
| Inbox | 1000 waiting messages per machine (the organization’s quota or the project’s budget may differ) |
| Rate | 600 messages a minute per project, 120 a minute to one machine (bursts allowed) |
| One wait | --timeout up to 3600 seconds |