Skip to content
The agent over ACP

The agent over ACP

Every agent has a machine of its own, made with the agent: your root agent’s when you first open a project, a subagent’s when an agent spawns one. On it the coding agent has no terminal of its own. It runs in ACP mode (Agent Client Protocol), and any number of clients share its one conversation:

  • The portal’s chat. A chat panel on one of the project’s screens is bound to an agent; Home has yours. On the canvas, open an agent’s chat from its card’s menu (or select it and press C): the page opens it as a panel (in its target stack, or in a side sheet), or focuses the chat panel of that agent it already has. Prompts typed there run in the same conversation.
  • Your own program. Any ACP client in the machine can attach with space-env acp attach as its agent command. It may speak ACP v1 or v2 (the draft): initialize with protocolVersion 2 or higher gets v2, anything lower gets v1, whichever the agent itself speaks. In v2, session/resume with replayFrom: {"type": "start"} replays the conversation so far, a message keeping the id its prompt was answered with. A prompt sent while someone else’s turn runs is answered when its own turn starts.

Preview

Agent machines and the chat are new. The conversation history that the portal shows is kept in memory by the region, and a region restart clears it. The machine keeps the conversation itself.

How many agents

Each member has at most a set number of agents in a project: their root agent and the subagents below it together, 5 unless the organization’s plan says otherwise (max_agents in space orgs show). It is never less than 1, so your root agent can always be made. Past it, a spawn is refused with a quota error that says so; the agent can delete one of its subagents first (delete_agent, which also deletes the agents below it and their machines). Other members and other projects count on their own.

Agents’ machines don’t count against the organization’s machines (max_machines), and neither do the machines the platform runs for it (an agent’s browser, the organization’s git): only the machines people and agents create to work on do. They still use the running vCPUs and memory, and disk, of the organization’s quota.

When your root agent can’t be made, the project page says why (the running machines use all the vCPUs or memory, say) and what to do, with a button to try again.

Which agent

The agent image has the ACP adapters of Mistral Vibe, Claude Code, Codex and pi. None runs until one is chosen, in the portal’s chat or here:

space-acp-agent           # prints the current agent
space-acp-agent claude    # switches to Claude Code: a new conversation starts

Or switch in the portal: choose Switch provider… in the menu of the chat’s model chip (top right of the chat). The chat stays open and asks which provider: Mistral Vibe, Claude Code or Codex, the one that runs marked. Choose another: the portal detaches the agent’s tools machine, if it has one, and writes the choice to the machine (its metadata cp/agent, which the machine follows), the agent starts again with it, and the conversation starts over: the chat says “restarting…” meanwhile, then shows the new provider’s conversation. When it needs a sign-in the chat asks for it at once (see Signing the agent in). Cancel, or the one that runs, changes nothing.

The running agent is the machine’s metadata agent/name (vibe, claude, codex or pi), which the portal shows on the machine’s card.

Agents run without permission prompts: the machine is the sandbox.

Which model

When the agent offers more than one model, the chat’s title bar shows the one it runs on as a chip. Press it and choose another: the agent changes at once, and every chat on the machine shows the new one. Claude Code offers its models (Default, Opus, Fable, Sonnet, Haiku) and Codex the ones your ChatGPT account has; Mistral Vibe offers the models in its configuration, one unless you add more, so its chat shows no chip.

The machine remembers the pick for each provider: a new conversation, a restart of the agent and a switch to another provider and back start with it again. A model the agent no longer offers is left out, and the agent’s default runs. The machine keeps the picks in /var/lib/space-env/acp/models, one line per provider (claude=sonnet).

The model the agent runs on is the machine’s metadata agent/model: its name, as the chat shows it. An agent that offers no choice of model has none.

Mistral Vibe runs without Mistral’s connectors and without its telemetry: the agent gets its tools from the machine. It fetches your Mistral organization’s Vibe settings through the platform, with the project’s Mistral key, so a start doesn’t wait on Mistral’s hosts.

Giving the agent files

To hand the agent files from your computer, press the paperclip at the left of the chat’s message box and pick them, drag them onto the chat panel (it lights up) and drop them there, or paste them into the message box (a screenshot or an image you copied). Each shows above the message box while it uploads; the × takes it off again. Send the message, or just the files, once they are up: a message waits for its uploads, and a file whose upload failed stays behind (with why) and isn’t sent.

Each file becomes an artifact of the project, named chat/<machine>/<date>-<time>-<n>-<file name> (UTC), up to 10 files a message and 1 GB a file (within the organization’s artifact quota). The message links them, and the agent gets them with space-env artifact get NAME, as it does a file sent on a chat app. Every other chat on the machine shows the files with the message.

Signing the agent in

When the agent has no key or account yet, the portal says so: the machine’s card shows sign in, and the agent’s chat panel asks for it. The machine’s metadata agent/auth is required until it is signed in, then ok.

  • With an API key (Mistral Vibe). The chat asks for the key, a credential request; paste it and press Send.
  • With a link (Claude, Codex). Choose Sign in with Claude or Sign in with ChatGPT: the machine runs the agent’s own sign-in (claude auth login, codex login --device-auth) and the chat shows Open the sign-in page, with the host it opens. For Claude, sign in there and paste the code the page shows into the chat’s field. For Codex, type the code the chat shows on that page; the chat goes on by itself once you have. If the code is refused, the chat says why and offers Sign in again. Cancel stops the sign-in. While the chat shows it, it is the only place that asks: the machine raises no credential request for the code as well.
  • In a terminal. In a shell of the machine, space-env acp login (or space-env acp login METHOD) runs the agent’s own sign-in.

Use another provider in the sign-in shows the providers instead, as Switch provider… does: the chat, and its menu, stays closed while the agent needs a sign-in.

A machine whose agent nobody chose yet asks in its chat: choose Mistral Vibe, Claude Code or Codex, and it starts with that one (and asks for its sign-in if it needs one).

When the sign-in ends the agent starts again, signed in. What it stored goes into your project’s credentials, not the machine:

  • An API key (Mistral, Anthropic, OpenAI) becomes the project’s credential of that provider. The machine keeps its placeholder, so every machine of the project uses the key.
  • A subscription (Claude, ChatGPT) becomes yours in the whole organization: the agents that run for you use it in every project, and nobody else’s do. You sign in once, from any of your agents. Signing in again, from any project, replaces it for all of them. The agent’s credentials file in the machine keeps placeholders, and the platform refreshes the tokens when they expire. In a region that can’t do that yet (its machines reach the provider directly), the sign-in stays in the machine instead, and space-env acp says so.

The project’s Credentials page lists them under Agent accounts, with the account each belongs to and the machine it was signed in from. A member’s subscription shows there with their name; only they can remove it. Your own are also under AI subscriptions in your account, per organization: Sign in again there to change accounts when a plan runs out (Credentials).

You can also add an API key on the Credentials page. On an agent machine the model gateway is always on: its agent reaches the providers with your project’s keys, also on a machine created before. When you have a Claude subscription and the project has no Anthropic API key, your agent machines use your subscription for Claude, in every project of the organization, without signing each one in. On any other machine, turn it on with space-env gateway on.

One conversation, several clients

  • Prompts run one at a time, in the order they arrive. A prompt sent while another runs waits for it.
  • Every client sees every turn. Another client’s prompt arrives as a user message, and then the agent’s answer and its tool calls stream as usual.
  • When the agent asks a question or for a permission, every client gets it. The first answer counts, and the others’ dialogs close.
  • Cancelling (Stop in the chat) stops the turn that is running, whoever started it.
  • Send now on a message of yours that waits for its turn stops the turn that is running, whoever started it, as Stop would, and runs your message next, ahead of every other that waits; the others keep their order. It is not added to the running turn: the agent answers one prompt at a time. In the chat, the button shows when you point at your waiting message (it is in the keyboard’s tab order, and always shown on a touch screen), and Enter in an empty message box sends the first of your waiting messages now, after you confirm.

Attach a program

space-env acp attach connects stdin and stdout to the conversation: newline-delimited JSON-RPC, the ACP agent side. --client sets the name the other clients see for your prompts.

space-env acp attach --client my-script

session/new returns the shared conversation rather than a new one, and session/load replays it from its start. The extension notifications _space/turn, _space/request_settled and _space/upstream tell a client what the others do, and _space/auth (state: required or ok, methods, account) whether the agent needs a sign-in; a client that doesn’t know them can ignore them. A method of kind link runs in the machine: _space/login_start {methodId} starts it, _space/auth’s login (state: starting, waiting, checking or failed; url, code, input, message) says where it is, _space/login_input {text} sends the page’s code when input is true, and _space/login_cancel stops it. _space/queued {prompts: [{client, prompt, id?}]} lists the prompts that wait for their turn, in order (id, the request id, only on your own), and _space/prompt_now {sessionId, id} sends one of your own now, as Send now does: the answer says whether a turn was cancelled ({"cancelled": true}), and a prompt that no longer waits is an error. A client that shows the sign-in in a dialog of its own sends _space/login_dialog {open} when it opens and closes: meanwhile the machine raises no credential request for the code.

How it runs

The service acp (space-env acp serve) starts the agent’s ACP adapter and serves the socket /run/space-env/acp.sock. It links the conversation to the region through the platform’s link-local address, which is how the portal reaches it. While a turn runs it holds the wake lock acp-turn, so the machine isn’t suspended in the middle of one. A waiting message to the agent becomes a prompt in the shared conversation.

When the agent dies

When the agent’s process ends (it crashed, or the machine ran out of memory and the kernel killed it), the hub starts it again and resumes the conversation, backing off from 1 to 30 seconds when it keeps dying. It also reports the exit to the platform as a machine event: how it ended (an exit code or a signal such as SIGKILL), whether a turn was running, and the conversation’s id. So do the machine’s other services when they die, a failed sync of the agent’s layers, and a wake lock that could not be taken or released.

Organization owners and admins read machine events in the portal’s Audit log, as Machine.agent_exit and so on, with the machine as “Who” and the message under “Details”. The machine’s own log, /var/log/space-env/acp.log, has the details.

A program of your own can report one too, on the guest API socket:

curl -s --unix-socket /run/space-env/api.sock http://space-env/v1/events \
  -H 'content-type: application/json' -d '{"kind": "nightly_import_failed", "level": "error", "message": "no rows", "data": {"rows": 0}}'

kind is lower case letters, digits and _; level is info, warning or error; message one line (cut at 500 characters); data a JSON object of at most 4 KiB. A machine reports at most about 10 events a minute.

When it dies during a turn

An agent machine is small, and a heavy install or a browser can use up its memory. The machine’s kernel then kills a process, often the agent. When the agent dies during a turn, or its adapter loses the conversation:

  • the turn ends with an error that says so in plain words (“The agent stopped: this machine ran out of memory and its kernel killed claude. It is starting again with this conversation; send your message again.”), in the chat and in every client;
  • the agent starts again and picks up the same conversation;
  • the portal opens an alert on the machine: Agent stopped mid-turn, and Out of memory: a process was killed for any process the kernel killed for memory. They clear a day after the last time it happened. The alert reaches the person the machine acts for as a notification, in their chat with the agent, on their phone or by mail.

The machine also gets a Memory pressure condition and alert when its available memory stays below 15% for two minutes (critical below 5%), so you can act before anything is killed. /var/log/space-env/acp.log in the machine has a line for each ended session, with its id.

Its tools in another machine

The agent’s machine is thin: it runs the agent and nothing else. Its tools run on another machine of its project, a Devbox for instance: the agent attaches them with space-env tools attach, and the canvas shows the work link. The agent’s own switch takes effect in its turn, from its next command on; one made on the canvas waits for the running turn. The conversation and its clients stay, and the agent knows where its tools run now. See Agent tool links.

Last updated on