Skip to content

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 0

The 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 receive claims the oldest message that matches and removes it from the inbox once it has printed it; no one else gets it. If receive is 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 next receive. Messages that don’t match the filter (--type, --context) stay for later.
  • Waiting is cheap. receive --timeout waits up to an hour for a message, without polling.
  • Two types. agent messages carry a request (--text, --data) or a reply (--reply), with a conversation id (--context) that replies copy. info messages (--info) are status lines that need no answer. The agent type follows the A2A Message shape: 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 is from schedule; one sent with space send is from user:<email>. The envelope’s from_kind tells them apart: vm for a machine, platform for everything else. A message sent in a conversation carries its context_id (a channel’s, see Reaching out). Forks can’t be named schedule, operator, owner or platform.

QoS: how hard to get the receiver’s attention

--qos says what the message does to a receiver that is busy or suspended:

QoSStoredResumes a suspended machine
whenever (default)yesno
notifyyesyes
urgentyesyes
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 receive has 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 send was made, the error says “temporary; try again” and the message may or may not be stored. receive is safe to repeat; check (space-env waiting in the receiver, or a reply) before repeating a send that matters twice.
  • A resume that fails. notify and urgent messages 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

Payload100 KB (the JSON of the parts); link to larger content with a URL
Lifetime24 hours unclaimed, then the message is erased
ReceiversMachines of the same project, by name
Inbox1000 waiting messages per machine (the organization’s quota or the project’s budget may differ)
Rate600 messages a minute per project, 120 a minute to one machine (bursts allowed)
One wait--timeout up to 3600 seconds
Last updated on