Skip to content
Reaching out

Reaching out

Messages go between machines. A channel carries a conversation between an agent and a person: its owner, on Telegram or Google Chat. Only agents talk on channels: the owner’s root agent of a project, and the subagents below it.

Chats are prompts

The platform runs the conversation for the agent. A Telegram or Google Chat message from the owner is a prompt to the agent, as if they typed it in its chat: their words, from a chat client named after the app and the owner (telegram · Ada, which the canvas’s chat shows). A file they sent is an artifact, given to the agent as a link (and, when it is an image and the agent takes images, as the image itself).

The agent just answers. Its reply goes back to the chat by itself:

  • At once the chat shows Thinking..., then the step the agent is on (at most every 5 seconds), or Queued: busy with … while it works on something else first.
  • A permission question (a tool the agent wants to run) is a message with a button per option. The first answer counts, from the chat or from the canvas.
  • The reply replaces Thinking.... A long one comes in up to three messages; a longer one as its first part with the whole reply as a .md file (an artifact). A turn that stopped at a limit offers Continue.
  • /cancel stops what the agent does for this chat: its own turn, or its messages still waiting. Work someone else asked for goes on.

To write to its owner first (done, blocked, a question), the agent runs space-env notify in its machine, with or without a chat: Markdown text, optionally an artifact to send along (a photo or a file on Telegram; Google Chat only names it), the --qos and a --channel to try first (an app the owner talks to the agent on, such as telegram, google_chat or slack, or app or mail). The portal picks the route (Notifications); the command waits up to 20 seconds for its answer and prints its one line, or says it was submitted without an answer, its delivery unknown. It exits 1 when the portal refused it or it failed.

space-env notify "Done: the **build** is green, MR !17 waits for your review."
space-env notify "Nightly run done." --qos whenever

When the owner has a chat with the agent, notify says so in a second line: the agent talks to them there, by answering, and notifies only when they aren’t talking to it. An agent without one (a subagent) notifies sparingly and coordinates with the agent that started it, with space-env send.

Under the hood the platform’s hub sends channel-neutral events for this, which the portal draws in each app’s own way:

TypePayload
channel.turn.queuedmessage_id (the owner’s message), busy
channel.turn.progressmessage_id, text
channel.turn.askmessage_id, request_id, title, options (id, name, kind)
channel.turn.settledmessage_id, request_id, option
channel.turn.replymessage_id, text (Markdown), stop_reason, error
channel.notifytext (Markdown), artifact, qos, channel, context_id, result (see Notifications)

A turn event carries the conversation’s context_id; the portal takes one only from the machine whose conversation that is.

Notifications

Every notify is kept as a notification of the person the machine acts for, whichever machine of theirs sent it, for 90 days. The portal’s bell (in the sidebar, and at the top on a phone) counts the ones they haven’t seen and lists them; opening one shows the agent’s chat on the canvas.

  • Where it goes. By its qos:

    qosSent
    whenevernowhere: the bell counts it
    notify (the default)the chat, and the owner’s phone when they paired the app; by mail only when neither took it, or when the agent asked for mail
    urgentthe chat, the phone and mail at once, and again every 10 minutes until it is seen, three times at most

    The chat is the machine’s own conversation with its owner, else the owner’s conversation with their root agent of the project, which says who wrote ("ana (agent): ..."); a reply there goes to the root agent. context_id is only a hint (a Google Chat thread). channel is tried first. Pushes and mails wait 30 seconds and come as one for everything that arrived meanwhile (“3 notifications from ana, web”); an urgent one doesn’t wait.

  • Seen. A notification is seen once its owner opens it in the portal or the app, taps its push, follows its mail’s link, or writes in the chat it went to. An urgent one stops repeating then.

  • The owner’s limits (Notifications). In their quiet hours (on, 22:00 to 07:00 on their clock, by default) a notify is kept and sent when they end; urgent comes through. An urgent past the owner’s limit a day for this agent (3 by default) is refused and not kept (state: refused): send it again as notify. A muted agent’s notifications, urgent too, are kept only. Past 30 in an hour from one agent, the rest are kept only.

  • The answer. With "result": true the portal answers channel.notify.result, in the request’s context, with one line for the agent (“Kept and sent to your owner on Telegram and on their phone.”, “Kept, not sent: whenever.”, “Kept. Your owner’s quiet hours last until 07:00 (Europe/Amsterdam); it goes to them then.”, “Refused: you used today’s 3 urgent notifications; send it as notify.”, “Failed: this machine acts for no one.”), or channel.notify.error with the reason when the message is malformed. Times are on the owner’s clock, in UTC when they set no time zone.

  • Later. Such an agent also hears what became of it: “Your owner saw your notification of 14:02 (Europe/Amsterdam).”, or that an urgent one went unseen for 30 minutes. This (channel.notify.update) starts no turn: it is a one-line note at the start of the agent’s next turn.

  • A machine that acts for no one (or for someone who left its organization) can’t notify.

The model

  • Owner. Every agent and its machine act on behalf of one person (on_behalf_of, see How it works). That person is its owner, and the only person it talks to on a channel.
  • Channel. One chat app (a Telegram bot, a Google Chat app), turned on for a project. Its conversations reach only agents of that project.
  • Link. A person’s account on that channel (their Telegram chat with the bot, their Google account), tied to their portal account once they have proven it is theirs. No link, no channel: an agent can’t reach anyone who hasn’t linked.
  • Conversation. One agent’s conversation with its owner on one channel (in the code: a binding). An agent has at most one per kind of channel. Linking makes the owner’s root agent of the project their coordinator, their main conversation, with no choice to make (it starts if it hasn’t yet).
  • Kinds. telegram, google_chat, and bugreport (a report to the platform’s team, not a conversation).

The messages

The platform carries these between the portal and the agent’s machine, where its hub turns them into prompts and turn events (above); the agent sees none of them.

DirectionTypefromContext
To the machinechannel.chat.<event> (message, untrusted, answer, cancel), the same for every app, which it namesthe owner’s name; for channel.chat.untrusted the sender’sthe conversation’s id (Google Chat: the thread’s, below)
To the machinechannel.<kind>.bound: the conversation existsthe platformthe conversation’s id
From the machinechannel.turn.*: with the conversation’s context_id; channel.notify(the machine)
  • The platform carries them unread. The region checks only that the type starts with channel. and the payload is a JSON object of at most 100 KB; the portal does the rest.
  • The conversation is the platform’s. An agent writes only in its own conversations: the portal takes a turn event only for a conversation of the machine that sent it, and a notify of another machine names its sender. Only the platform sends channel.* to a machine, so nothing can pose as its owner. An app’s own messages (channel.telegram.sendMessage, …) are not sent.
  • Incoming messages resume the machine. They arrive with QoS notify (see QoS).
  • Files are artifacts. A file that arrives is stored as an artifact of the project; the agent gets a link to it (space-env artifact get NAME).

What an agent knows about its conversations

space-env meta get shows read-only keys the portal sets, also after a restore (the agent may not remember earlier messages, but the conversation stays):

KeyValue
cp/channelsthe kinds the owner talks to this agent on, comma-separated (google_chat,telegram)
cp/channel.<kind>that conversation’s context id

The machine’s label metadata names it on the chat app, and its agent/status and agent/status_text (Metadata) show its status there.

Lifecycle

  • A conversation starts when the owner links their account (the coordinator) or opens a topic with /new (Telegram). The agent is told how chats work when it does.
  • A conversation whose coordinator is gone (its machine deleted) comes back with the owner’s next message there: their root agent becomes the coordinator again.
  • A restore keeps a conversation (same machine).
  • It ends for good when the machine is deleted, when it no longer runs an agent of its owner, when the owner unlinks or leaves the organization, or when the channel is turned off.

Telegram

The owner’s private chat with the project’s bot. Their coordinator, their root agent in the project, has the chat’s off-topic area: their main conversation (coordinator: true in bound). /new there opens a topic with another of their agents (a subagent), and /status shows what their agents do.

TypePayload
channel.telegram.message (in)Telegram’s Message (text, caption, …); a photo or file is {"artifact": NAME} (files up to 20 MB)
channel.telegram.answer, channel.telegram.cancel (in)a tap on a permission question’s button or Continue, and /cancel

Nothing Telegram’s own goes out: the agent’s turns and notify are drawn by the portal (a photo or file sent along up to 10 MB or 50 MB).

Google Chat

The project’s own Chat app (its admin sets it up in their Google Cloud project, see Google Chat). An owner has one conversation there: their DM with the app, with their coordinator, their root agent in the project. Only the coordinator is on Google Chat.

TypePayloadContext
channel.google_chat.message (in)Chat’s Message (text, argumentText without the @mention, sender, thread, space); an uploaded file is {"artifact": NAME, "contentName", "contentType"}, a Drive file {"contentName", "contentType", "driveFileId", "link"}the DM: the conversation’s id; a space: the thread’s
channel.google_chat.untrusted (in)the same, plus sender (id, name, email), why and eventthe thread’s
channel.google_chat.answer, channel.google_chat.cancel (in)a click on a permission question’s button or Continue, and /cancelas the message
  • Spaces. The owner adds the app to a space and @mentions it; that thread is then its own context, and the agent’s reply goes into the thread. The app sees only messages that @mention it.
  • Others in the thread who @mention the app arrive as channel.google_chat.untrusted: not hostile, but not the owner, and the agent’s prompt says so.
  • Where the agent writes. In the DM, or in a thread it was asked in; never a new thread or a space’s top level. A thread whose space removed the app is gone.
  • No files out. Chat doesn’t let an app upload files: notify names the artifact.

Bug reports

space-env bugreport sends channel.bugreport.create ({"description": ...}, with "kind": "feature" for --feature, a feature request) to the platform’s team, as the owner (see Reporting a bug). It is not a conversation: the answer goes to the owner by email, and only a refusal comes back, as channel.bugreport.error.

Last updated on