agent-connect
Connect your own local agent (Codex, Hermes, …) to s.space.
You run a coding/agent CLI locally (with your own creds and your own repos).
agent-connect lets that local agent appear as a first-class agent in s.space
rooms: people !codex … (or @-mention it) in a room, the task is routed to
your agent, your machine runs it, and the result is posted back.
Why a local worker (and not "just a server bot")
The whole point is your local agent — your API key, your working copy. A browser or a server can't run your local CLI or see your repos. So agent-connect is a tiny thing that runs on your machine:
- Setup happens in the web Agent Portal (create the agent, get a token + a one-line command). No desktop app required.
- Execution happens locally via this worker — one command links your machine, like a self-hosted CI runner.
How it reuses s.space infra (no new appservice)
s.space's relay is already a generic outbound transport: a client on your
machine connects out and long-polls GET /v1/tasks for your agent
(identified by your token). Appservices (which require the homeserver to reach
you) don't scale to laptops behind NAT; the outbound relay does.
agent-connect speaks that relay itself, through ag2-relay-client — a
stdlib-only library published from this repository (relay-client/) that owns
the whole wire: the long poll, the lease, the acknowledgement, results,
heartbeats and room ops. The worker holds it in-process and takes tasks off its
queue. There is no task directory between the two and no second process: the
delivery guarantee was never a file queue's, it is the broker's lease, and a
worker restarting mid-task now re-completes the answer it already gave rather
than running the turn again.
room "!codex fix the flaky test"
│ (relay routes to your Codex agent's token)
▼
agent-connect ── ag2-relay-client ──► GET /v1/tasks (long poll, leased)
│
the worker ──► codex exec --sandbox <tier> --cd <repo> "<task>"
│
ag2-relay-client ──► POST /v1/results ──► posted back to the room
Access tiers (safety)
This is the promise, in one sentence, and it is the same sentence the Agent Portal makes:
The broker attests every task's sender; the Worker trusts the attestation; owner tier → workspace write; guest → read-only sandbox on the codex path and a polite refusal on the ACP path; anyone in the room is attested guest already, and
allow @user/trust @user— said in a direct message to the concierge,@sutando-concierge:<your homeserver>— set which tier a sender is attested at; the host may explicitly override a specific sender locally.
Unpacked:
Two tiers cross the wire, and only two. The broker knows who sent the
message, works out how much you trust them, and writes access_tier: owner or
access_tier: guest on the task. The worker acts on what the broker said and
does not re-decide it — that attestation is the only thing standing between an
allowed stranger and your files. A task whose tier is missing, duplicated or
unrecognised is treated as guest, never owner: the absence of an
attestation is not a grant of one (docs/adr/0003).
Owner is a trust level, not a person. You, who registered the agent, are
owner. trust @user makes someone else owner too; allow @user names someone
as a guest. Both are yours to give and yours to take back.
They are a dial, not a door. Somebody who is in a room with your agent can
address it already: they arrive attested guest by default and get whatever
guest gets on your adapter, allow or no allow. What these two commands
change is which tier a sender is attested at — they are not what lets anyone
in, and withholding one keeps nobody out. The way to keep somebody out is to not
have them in the room.
Both are commands to the concierge, and to nothing else. Say them in a
direct message to @sutando-concierge:<your homeserver> — the same bot that
registered the agent for you. Typed anywhere else they are not commands at all:
in your agent's room, or in a direct message to the agent, trust @user is
ordinary text arriving at a language model. The platform answers such a message
with a one-line pointer back to the concierge rather than acting on it, and
nothing is granted. The concierge is deliberately not a member of your agent's
rooms, so looking around will not find it — this line is where the recipient is
written down.
trust hands over more than the word suggests. Both of the following are
standing behaviour rather than rough edges awaiting a fix, and both are worth
knowing before you grant it:
- It applies to every agent you own, not the one you had in mind. Trust is
modelled as a relationship between people, so a single
trust @usermakes that person owner on all of your agents at once — the concierge's reply lists which ones.untrust @usertakes it back everywhere in the same one go. - They do not get a session of their own — they continue yours. A session is
keyed by room and access tier together (see The agent remembers the
conversation), so a second
owner-tier sender in the same room lands in the same session you left there:
the same session id, the same working directory, and whatever context your own
conversation has already accumulated in it.
trusttherefore shares a live conversation as well as workspace write. This was weighed and kept deliberately — it is part of what owner tier means here.
What each tier gets depends on the adapter, and the difference is not cosmetic:
- owner →
workspace-write(edit files, run builds), on every adapter. - guest, on the codex path →
read-only(read/analyse/answer only). This is operating-system confinement: the sandbox is enforced by the agent CLI and the OS, so an agent that ignores it is still stopped. - guest, on the ACP path → a polite refusal in the room, and no run at all. ACP has no sandbox to fall back to — see the next section — so there is no read-only tier to offer, and offering one anyway would be a limit that only looks like one. The refusal is a visible reply, not silence: it is posted the same way as an answer, so the guest reads a sentence saying what happened and what would change it.
You can lower a specific sender on your own machine. The relay client's
local access.json tier map is yours, and it is a cap, not a re-tier: the
tier a task runs at is the lower of what the broker attested and what your map
allows, so the map can take trust away from a named sender on this host and can
never hand any out. Nothing a sender writes touches it either way.
Team collaborators
What a Team collaborator is
In s.space a room can grant a member Team — collaborator access, through
the room's Agent Native settings. The broker attests it on each task, beside
the tier: access_tier or requested_access_tier is team and collaborator
is the boolean true. agent-connect trusts that attestation only when both are
there, exactly as sent, and the task names its sender (a non-empty user id).
Who the room grants it to is set in s.space, not on your machine:
- A private room with no Agent Native card makes every member a collaborator by default.
- Room moderators, not only you, can change a room's grants.
What it means for your agent
The room's grant alone gives a collaborator nothing extra:
- codex path: a collaborator runs as a guest, in the read-only sandbox.
- cline, kilo and omnigent paths: a collaborator is a guest too, but only codex enforces read-only. These adapters only tell the agent the files are read-only, so a guest, collaborator or not, gets the tool's full autonomy.
- ACP path: a collaborator is refused, with a reply in the room saying what would change that, until you admit them on this machine. The room's grant is still required: your setting only narrows who the room allows.
How you control it
Pick one of three scopes. Named senders and named rooms combine: a sender is
admitted if either lets them in. "Everyone" replaces named senders, since both
use the same setting; a * mixed with ids is refused by the installer and is
not * to the Worker.
| Scope | Installer flag | Setting | Who is admitted |
|---|---|---|---|
| Named senders | --collaborators "@a:s.space,@b:s.space" |
AGENT_CONNECT_ACP_COLLABORATORS |
Only those full Matrix ids, where a room grants them collaborator |
| Named rooms | --collaborator-rooms "!room:s.space" |
AGENT_CONNECT_ACP_COLLABORATOR_ROOMS |
Every collaborator in those rooms |
| Everyone | --collaborators all |
AGENT_CONNECT_ACP_COLLABORATORS=* |
Every collaborator in every room this agent is in, now or later |
- Re-running the installer keeps the values. Pass
""to clear one, for example--collaborators "". - The Worker reads them at start, so restart it after editing
config.envby hand. - Narrowest first: the "Everyone" scope plus the private-room default means every member of every private room your agent is in. Prefer named senders, or named rooms you moderate.
What an admitted collaborator gets
-
Their own Session per room, never yours. The agent is told who asked, in
_meta["ag2/requester"]and the routing record. -
The agent's normal capabilities: its tools, its working directory and its host's permission policy. Admit only senders you would let act as you on this agent.
-
Guidance in the prompt. The agent is told to get your approval before it does any of these:
- changes files outside its working directory;
- changes its own settings, permissions, skills, memory or credentials;
- installs software;
- posts anywhere but its reply, or acts on outside services;
- reads your private data.
Without your approval it declines that part, says the sender can ask you, and answers the rest. Only the host's approval prompt, or a message from you, counts as your approval. A collaborator saying you agreed does not.
-
agent-connect's permission check, when the host asks. If the host asks agent-connect for permission, a request whose paths are all inside the working directory is allowed. Anything else, including most shell commands, which name no paths, goes to you as a private Allow/Deny question that names the collaborator.
-
A check on the reply. A reply that matches a known secret format, or carries a file, is withheld. You are asked privately whether to post it.
AGENT_CONNECT_UNCHECKED_COLLABORATORS=1turns off the secret and file check. A[channel:]redirect is still held.
What it does not protect
- The guidance is advisory, not enforcement. agent-connect's own check runs
only when the host asks for permission. A host that never asks is not
stopped: for example, OpenClaw with
approval_policy=neverasks nobody, so an admitted collaborator's commands run without you being asked. agent-connect does not yet restrict collaborator sessions by itself (for example through a restrictive session mode). Tighten the host's policy if that matters. - Files inside the working directory are not protected. A collaborator can ask the agent to change or delete them.
- Your scheduled tasks are reachable. A collaborator can steer the agent into changing and running one of your scheduled tasks, and that task's outcome is posted unchecked.
- Posts through the s.space MCP are not checked. agent-connect checks only the answer it posts. Withhold that MCP from collaborator sessions, or make it read-only, if your host can.
- On one OS user this is a trust boundary, not tamper resistance. The agent
can edit
config.env, the launcher or agent-connect itself. Run it as another OS user, or in its host's sandbox, if that matters.
To revoke access, clear the setting and restart the Worker, or have the room remove the collaborator grant.
The ACP adapter: cooperative confinement
The acp adapter drives any agent that speaks the Agent Client
Protocol (Claude Code via
@agentclientprotocol/claude-agent-acp, Cline, PI, …). Its safety story is
different from every other adapter's, and weaker. Read this before enabling it.
- There is no sandbox. ACP gives the OS no say in what the agent touches. The agent does its own file access and asks the worker for permission as it goes.
- The limit is a permission policy, and it is cooperative. agent-connect allows operations under the session's working directory and rejects the rest — but that binds only an agent that chooses to ask. An agent that just writes the file is not stopped, because nothing is there to stop it. It is a convention, not a guarantee; it is not a substitute for a sandbox.
- Owner-tier under ACP is therefore MORE permissive than owner-tier under
codex. Same tier, weaker confinement: codex runs owner-tier tasks under
codex exec --sandbox workspace-write, where the OS refuses writes outside the workspace whatever the agent tries; ACP has no such boundary, only the cooperative policy above. Network is not the difference — agent-connect turns network access on for owner-tier codex tasks too (sandbox_workspace_write.network_access=true, seeagent_connect/adapters/codex.py); it is off only for guest/read-only tasks, which never reach ACP at all. - Guest tasks are refused outright and never reach ACP — the ACP agent is
not even started. Shipping a read-only tier on top of a cooperative policy
would be offering a limit that only looks like one. The refusal is said in
the room, as the reply to the message that asked, and it names what would
change the answer: Collaborator access in the room plus a place on this
agent's collaborators, or
trust @usersent to the concierge, by full MXID, because an instruction whose recipient is missing is not one. A guest who hears nothing cannot tell a refusal from a broken worker, and reports the wrong problem.
Name your agent and the worker knows what to run:
export AGENT_CONNECT_ADAPTER=acp
export AGENT_CONNECT_ACP_AGENT=claude # a preset: claude | gemini
export AGENT_CONNECT_REPO=/path/to/the/repo # the session's working directory
Or install it in one line, with the bridge pinned for you:
curl -fsSL <installer-url>/install.sh | sh -s -- --token <TOKEN> --adapter acp --acp-agent claude
Presets never block you. They live in code (agent_connect/adapters/acp.py)
and cover the agents we know about. For anything else, give the command
yourself — it overrides every preset:
export AGENT_CONNECT_ACP_COMMAND="my-agent --acp"
The installer takes the same thing as a flag, so an agent no preset describes is still a one-liner:
curl -fsSL <installer-url>/install.sh | sh -s -- --token <TOKEN> \
--adapter acp --acp-command "my-agent --acp"
--acp-command implies --acp-agent custom: a supplied command overrides every
preset anyway, so naming a preset would only npm-install a bridge you are not
using and make a login failure name an agent you are not running. Pass
--acp-agent as well if you want a different name recorded.
Re-running the installer without --acp-command keeps whatever command is
already in config.env, and keeps the agent name beside it — a plain re-run to
upgrade the worker does not quietly re-point your agent.
Naming a preset is how you switch back. --adapter acp --acp-agent claude on a
later run clears a stored AGENT_CONNECT_ACP_COMMAND, because a command
overrides every preset: keeping it would leave the old agent running while the
installer reported the preset you asked for. The installer says so when it
happens, and the previous file is at config.env.bak. An install for a
different adapter never touches these two keys — --acp-agent is ignored there,
out loud, and your ACP settings are left as they are.
Startup checks, not surprises in a room. Before the worker serves its first
task it starts the ACP agent, runs initialize, and stops with a sentence you
can act on if the bridge is not installed (naming the package and the install
line) or if the local agent is not logged in (naming the login command). It
opens no session and sends no prompt, so the check costs no tokens. The worker
never opens an interactive terminal on your machine — ACP has a way for an
agent to ask for one and agent-connect does not implement it, so logging in is
something you do yourself, in your own shell.
Refused permission requests are reported back in the reply, so a blocked agent is distinguishable from a lazy one.
The bridge is pinned. @agentclientprotocol/claude-agent-acp@0.64.2 — the
version a full turn was actually run against. It renamed itself once and moves
through major versions fast, so the installer never fetches @latest. The pin
lives in two places that install.test.sh forces to agree: ACP_BRIDGE_SPEC in
install.sh and BRIDGE_VERSION in agent_connect/adapters/acp.py.
Dialling an agent that is already running
The adapter can also reach an ACP agent that is already up, over a WebSocket, instead of starting one per message:
./install.sh --token <token> --adapter acp \
--acp-url ws://127.0.0.1:8802/acp --acp-token <the listener's token>
pip install 'ag2-agent-connect[websocket]' # the SDK's transport extra
Why you would: spawning is a cold start per room message. An agent whose entrypoint builds a whole runtime — a gateway, MCP servers — pays for all of it on every message and throws it away after one turn. An agent that hosts its listener inside the process serving its own UI can also stream a turn into a page you already have open; over stdio that turn happens inside a subprocess your UI has no connection to.
Four things worth knowing before you use it:
- A URL and a command are refused together, rather than one winning. They name two different agents, and a worker that guessed would answer your rooms as one nobody picked. Unset whichever you do not want.
- A dial that fails stays failed. Nothing is spawned to cover for a door that is down — that would substitute a different agent exactly when nobody is looking.
- Loopback unless you say otherwise, and
wss://beyond it. The permission policy that guards file operations resolves paths on this machine; against an agent on another host its answers are guesses shaped like a guarantee.AGENT_CONNECT_ACP_ALLOW_REMOTE=1is how you accept that, deliberately. It does not cover putting the credential on the wire: the bearer travels on the handshake, so a non-loopback URL must bewss://. Plaintextws://stays fine on loopback, where nothing leaves the machine. Credentials written into the URL itself are refused — the bearer belongs inAGENT_CONNECT_ACP_TOKEN. - The working directory is the remote's.
session/newrequires one, so the worker always sends a value: its own directory, which on loopback is a real path on the same filesystem, orAGENT_CONNECT_ACP_REMOTE_CWDwhen you are dialling another host and this machine's paths mean nothing there. A session is retired when that directory changes, not when the worker's own does — and the permission policy judges the same directory the session was opened in. - A turn that overruns can only be asked to stop.
session/cancelis sent first, as it always was. If the agent ignores it, a spawned agent's process is ended; a dialled one is not yours to end, so the connection is dropped and the room is told it may still be working.
The bearer travels on the WebSocket handshake, is read fresh on every dial (so
rotating it needs no restart), and lives in the same 0600 config file as your
relay token. See docs/adr/0004 for the reasoning, including what this costs.
Replies: one answer, posted by the broker
The worker posts no placeholder and edits nothing into an answer. s.space shows
the request's status from core-api's activity ledger: queued, then working once
the relay client acknowledges the task, then replied when the answer is posted.
A turn ends in one result (docs/adr/0002, amended for 0.4.0):
- An answer is completed with
status: "completed", and the broker posts it once, as a reply to the request. Files it names are uploaded first. - Nothing to say (no text, or the agent replies
NO_REPLY, followed only by its Activity lines) is completed withstatus: "no_action_needed": nothing is posted, nobody is mentioned, and the activity ledger records no action. Agents are told to use it for acknowledgements, thanks and FYIs, which keeps agent exchanges from looping. - A turn that produced nothing and did not end normally is
failed, and the broker posts its one failure notice. If the adapter explained the failure (not configured, not logged in), that explanation is the answer instead.
Activity labels. The agent is asked to end every reply with two lines for your Activity page:
[activity:title] Fix login redirect
[activity:outcome] Fixed the redirect loop and ran the tests.
agent-connect removes them before the reply is posted and sends them with the
result as the row's title (at most 60 characters) and outcome (at most 150;
the agent is asked for 120, leaving headroom, as ag2-sparrow does).
Only you and the agent see them, not the room.
- Which lines count: only the final lines, outside any code block.
- Missing or malformed lines: the reply is posted unchanged and the row shows the request text, as before.
- Hosts that send metadata: a host that puts
_meta["ag2/activity"] = {"title": …, "outcome": …}on its ACP prompt response takes precedence over the lines. - Status: labels never change a result's status.
- A failed turn keeps only its title, since its outcome line could claim a success.
- A no-reply turn without an outcome line is labelled "The agent had nothing to add."
- Collaborators: their labels go through the same secret check as their reply. A label the check would hold is dropped.
Reported tool failures and permission refusals appear in the answer as aggregate lines. Raw tool titles and permission details never reach the room: they can contain code, arguments and local paths. Bounded operator diagnostics (last 50 events, 500 characters each) go only into the archived result of a failed turn. The model's internal reasoning never reaches the room.
The worker never speaks Matrix: notices it posts itself (a session reset, a reply
withheld for review) are room ops the relay performs as your agent identity
(docs/adr/0002).
Hand-offs are addressed by mxid. In a room shared with another agent, the broker delivers a message to that agent only when the agent's full mxid is on it — stamped as a mention, or written whole in the body — and an agent ignores agent-authored messages it is not named in. So the worker tells the local agent who is in the room and how a hand-off is delivered (the roster, the addressee and the reply facts the broker sends with each task reach it in the preamble), and a message the worker posts is stamped for the room members whose mxids it names.
If the relay refuses a room op for a notice, the notice leads the answer instead, so it is never lost.
What the agent says unasked comes back to the room (ACP)
A dialled agent can speak first. AG2 Assistant runs scheduled tasks; one created from a room
finishes hours later, and its outcome arrives as an ACP extension notification,
_ag2/notify, which agent-connect posts to the room it names. Two things make that work and
neither needs a setting:
- every Session is opened with the room as its destination (
_meta["ag2/destination"]onsession/new), so the agent knows where a Task created in it belongs; - a dialled agent gets a listener link — one standing dial the Worker keeps open, re-dialled after a pause when it drops — so there is a client to deliver to between Turns. The agent queues while there is none, so a Worker that was down gets what it missed on its next dial.
Only a connection that can deliver asks for the queue: the link and a Turn's dial say so on
initialize (_meta["ag2/receive"] = true), the startup preflight does not, and the agent
flushes to the ones that asked. A spawned agent needs no link: it only exists during a Turn,
whose own dial listens too. See docs/adr/0005.
The agent remembers the conversation (ACP)
Ask for something, then say "now the same for the other module", and it works: each room continues one conversation with your local agent instead of starting over every message. The session is keyed by room and access tier together, never by room alone — a session carries a permission mode and its own context, and a lower-trust request must inherit neither.
The session survives you restarting the worker: the identifier is kept in
<workspace>/sessions.json and resumed on the next message. Resuming makes the
local agent replay the whole prior exchange, which the worker consumes in a
suppressed mode that posts nothing — restarting must not dump yesterday's
transcript into a live room.
Memory is bounded, and its ending is announced. A session retires after
AGENT_CONNECT_SESSION_TURNS turns or AGENT_CONNECT_SESSION_IDLE seconds of
silence, and the room is told, in its own message, that the context was reset
and why. The same message appears when a conversation cannot be resumed — an
agent that refuses, or one that never offered resumption at all: the request is
answered from a fresh session rather than failed. Silent amnesia is the problem
being solved, so nothing here happens quietly. Set
AGENT_CONNECT_SESSION_MEMORY=0 and every message starts fresh, as it did
before.
Only the ACP adapter has this. The other five run a one-shot CLI per task and have no session to continue.
Nothing is lost, and endings tell the truth
A message that arrives while the agent is busy is queued. Only one turn at a time may be open on a session — the protocol's rule, not a choice — so a second message in the same room waits for the first, and s.space shows it as queued until its turn starts. Queueing is per session, so a room that is busy blocks nothing but itself and every other room keeps running.
A turn that runs too long is cancelled through the protocol, never by killing
the agent. After AGENT_CONNECT_TURN_TIMEOUT seconds the worker sends
session/cancel; the local agent stops and hands back everything it had
produced. That partial answer goes to the room with the interruption stated
plainly — long work that nearly finished is not thrown away, and an answer cut
off mid-sentence with no note reads as a complete one. Ending the process is
the last resort, only after a cancellation the agent ignored, and it takes that
one turn's process with it and no other room's conversation.
A turn that produced nothing produces no reply from the worker. A refusal,
a deadline that arrived before any output, a bridge that died: each is written
as a [no-send] result, which the relay client archives and delivers nowhere.
The failure notice in the room is the broker's to post, and two apologies for
one failure is worse than one. Nothing about it is silent, though: the reason is
in the archived result, and any stop reason other than a finished answer always
appears as its own line rather than as silence.
The local agent's process dying does not end the worker. One crash is one turn's failure. The session identifier is kept, so the next message in that room resumes the conversation rather than starting over.
A screenshot you drop in the room is a screenshot the agent sees
Attach an image to a message and ask what is wrong with it, and the local agent is shown the image — as content of the prompt, beside your text, not as a filename it is told to go and open. The relay client has already downloaded the file by the time the worker sees the task, so nothing is fetched from the room. Several attachments on one message are all passed, in the order you sent them, and your own text goes through untouched.
Nothing is converted, resized or transcoded. The bytes the agent receives
are the bytes on disk. AGENT_CONNECT_ATTACHMENT_MAX_BYTES bounds how much of
one file is read, and a file over it is reported, never shrunk to fit — a
resized screenshot is a different screenshot.
An attachment the agent cannot take is said out loud. What it accepts is
what it advertised when the worker connected to it (ACP's promptCapabilities);
a kind it did not advertise, a file that has gone missing, a file over the
limit — each is named in the room, with the reason, and with the suggestion to
paste the content instead. The failure a person can act on is better than the
one they find out about by reading an answer that ignored their screenshot.
The other adapters run through a plain command line that takes text and nothing else. They say exactly that, for the same reason — and they do not pass the file's path to the agent instead: that would tell it to go and read a file from a directory the relay owns, which is not what someone attaching a picture asked for.
A file the agent produced arrives in the room
Ask for a report, a diff or a chart and the file itself lands in the room —
openable, not pasted into a code block. The agent writes the file in its working
directory and names it in its reply ([file: report.md] on a line of its own);
the worker takes the marker out of the text, so the room reads prose and receives
the file beside it, as one reply. Several files from one turn all arrive, in the
order the agent named them.
The route matters more than the feature. A file goes out through the relay
client's egress allowlist: a list of directories, fixed when the worker
builds the client and impossible to widen afterwards, holding the working
directory the agent runs in and anything you added in
AGENT_CONNECT_EGRESS_ROOTS. The allowlist is what stops an agent from being
talked into attaching a private key or somebody's tax return to a chat message.
Restricting the ACP adapter to the owner narrows who can try; it does not close
it, because the owner in a room is not necessarily the person sitting at the
machine.
The check runs inside this process, on the open file descriptor rather than
on the path: resolved first, then opened one directory component at a time with
O_NOFOLLOW, then judged by fstat for regular-file-ness, size and a single
hard link. It used to run in a separate process, and workspace docs/adr/0001
records the loss of that separation honestly — the guarantee stays permission
policy, not confinement, which is what it always was, since the worker has always
held the token.
A file outside the allowlisted directories is not sent, and the room is told so — by name and with the reason, in the same reply. A file that silently fails to arrive is indistinguishable from an agent that ignored the request. The same line appears for a file that has gone missing, one that is not a regular file, one reached through a symlink pointing out of the permitted area, and one over the relay's upload ceiling.
What this does not prevent: an agent talked into copying a private file into its working directory can then send the copy. The permitted area is a boundary on paths, not a proof about contents — closing that needs a sandbox that refuses the first copy.
The config file: settings written down, not exported
Everything below is an environment variable, which is a fine interface for a shell and a poor one for a service. So the same keys can be written in a file instead, and the worker reads it itself:
install -m 600 /dev/null ~/.agent-connect/config.env
cat > ~/.agent-connect/config.env <<'EOF'
AGENT_CONNECT_TOKEN=<token from the portal>
AGENT_CONNECT_ADAPTER=acp
AGENT_CONNECT_ACP_AGENT=claude
AGENT_CONNECT_REPO=/Users/me/agents
EOF
agent-connect
The keys are the ones in the Settings table below — the same names, no
translation, nothing to learn twice. KEY=value, one per line, # comments,
everything after the first = taken verbatim (one matching pair of surrounding
quotes is removed, and that is the whole of the syntax). It is not a shell
script and is never evaluated as one, so the launcher and the worker read the
same file and agree about what it says.
Where it looks, in order: --config <path> on the command line, then
AGENT_CONNECT_CONFIG, then ~/.agent-connect/config.env if it exists. The
flag exists so a start needs no environment at all; the variable exists so a
service unit can point at a file without putting anything else on a command
line. A file you named and that is not there stops the worker — it holds the
token, and starting without it gives you a worker that runs, pulls nothing and
looks healthy.
Environment variables win over the file. A setting already exported is left exactly as it is, per setting, and the worker says which ones the file offered and did not get:
agent-connect: config /Users/me/.agent-connect/config.env — 4 setting(s) applied,
1 already set in the environment (AGENT_CONNECT_ADAPTER) and left alone
That direction is the only one that makes AGENT_CONNECT_ADAPTER=codex agent-connect mean what it says. A config file is a default that persists, not
an authority that overrules the shell you are standing in.
It may set settings and nothing else. Only AGENT_CONNECT_*,
REMOTE_TASK_* and OLLAMA_HOST are applied; any other key is named on stderr
and ignored, because a file that could set PATH would be deciding which
codex binary runs. A misspelt setting is named for the same reason: it looks
exactly like a setting that did not work. A key written twice takes the last
line, as it would in any file of this shape, and the repetition is named too —
that one is worth being sure about when the setting is a token.
There is exactly one parser, and the launchers ask it. A launcher has to
know a setting or two of its own — whether there is a token at all, which
workspace's pidfile to clear — so launch.sh and run-agent.sh run
_cfg="$(agent-connect --export-config)" || exit 1
eval "$_cfg"
which prints the config file as export lines — with the environment's own
values already deferred to — and nothing else on stdout. The shell loop that
used to do this instead disagreed with the worker about duplicated keys, CRLF
line endings and whitespace-only variables; the first of those handed the relay
client and the worker different tokens out of one file. Two readers of one
file is two answers to "what does this file say".
It holds your agent's token, so keep it to yourself. The installer writes it
0600. A file others can read is still loaded — refusing would break a working
install over a warning's worth of problem — and complained about at every start,
with the chmod that fixes it.
This is what the installer now does. install.sh writes your token, adapter
and working directory into that file and points the launchd plist (or systemd
unit) at it with AGENT_CONNECT_CONFIG, so the service definition carries no
bearer token — it used to sit in plaintext in
~/Library/LaunchAgents/space.ag2.agent-connect.plist, which is world-readable
by default. Re-running the installer keeps the previous file as
config.env.bak and carries across every key it does not manage itself, so a
setting you added by hand survives a re-run of the one-liner.
Running more than one agent on one machine
Give each agent its own instance. The web setup flow passes the agent's full Matrix identity so the installer derives a stable name:
./install.sh --token '<gateway>|<agent-one-token>' --adapter codex --agent-id '@owner-codex-one.agent:example.org'
./install.sh --token '<gateway>|<agent-two-token>' --adapter codex --agent-id '@owner-codex-two.agent:example.org'
Each gets its own private config, launcher, workspace, log and background
service under ~/.agent-connect/instances/agent-<identity-hash>/. The hash uses
the full identity including its homeserver, not the token: reconnecting or
rotating a token reuses that agent's instance. Codex and Claude can run beside
each other in the same way. Two agents may use the same working repository;
their connector state still lives in separate workspaces.
For a manual install, --instance codex-one is an alternative to --agent-id.
Names use 1–32 lowercase letters, digits, _ or -. Reuse the same name when
reconnecting that agent. Do not run the same agent credential in two instances.
AGENT_CONNECT_INSTANCE is the environment default for the install location
and service as well as the worker's status label. An explicit --instance
overrides that default; --agent-id ignores it and derives the name from the
identity instead. Passing both explicit flags is refused.
Without either flag, the legacy single-agent location and service remain the
default. Reinstalling there replaces that one connection. A named install leaves
a different agent's legacy service alone. When the legacy service has the exact
same credential, a normal install retires that service before starting the named
one; its old config and workspace remain on disk. --no-start changes no service.
Without launchd/systemd, stop the matching legacy worker before starting its
replacement as a named instance.
Legacy migration cleanup
Automatic migration can identify the legacy connection only by an exact credential match. If you rotated its token before reinstalling, the installer cannot tell that revoked token from another agent's credential: it leaves the legacy service alone and prints a cleanup note. That obsolete service can keep restarting with the revoked token until you stop it.
After confirming the legacy default belongs to the agent you migrated, stop and disable only that default service. Keep it running if it belongs to another working agent. On macOS, unload it if it is currently loaded, then move its plist out of the login service list:
legacy_plist="$HOME/Library/LaunchAgents/space.ag2.agent-connect.plist"
if launchctl print "gui/$(id -u)/space.ag2.agent-connect" >/dev/null 2>&1; then
launchctl unload "$legacy_plist" && mv "$legacy_plist" "$legacy_plist.retired"
else
mv "$legacy_plist" "$legacy_plist.retired"
fi
With systemd:
systemctl --user disable --now agent-connect.service
The named services have different names and remain running. The legacy config and workspace can stay on disk; removing the agent identity or its chat history is unnecessary.
The broader installer work in issue #32 also requests refusing a different credential in a flagless legacy install and listing installed/online agents. Those remain follow-ups; flagless installs still replace the legacy connection, and this installer does not provide an agent inventory/status command. Use one of the selectors above for each agent.
The launch unit is one worker pointed at one config file. That is the contract a supervisor builds on, and it is deliberately not a wire: what a supervisor should depend on is the unit, named by the config file it was given.
agent-connect --config ~/.agent-connect/instances/scratch/config.env
Today that unit is one process, and a supervisor may rely on it. The worker
carries its own relay client (workspace ADR 0001), so there is nothing to start
beside it — install.sh writes a launch.sh that execs the worker and nothing
else. It was a pair once, worker plus a separate ag2-sparrow process, and the
pair was not merely one process too many: both halves long-polled the gateway
with the same bearer and excluded each other from nothing, so whichever won a
given long-poll took the task. When ag2-sparrow won, the task went into a
directory the worker no longer reads, and the person who sent the message got
no answer and no error. If you are supervising a worker installed before this
changed, re-run install.sh — an old launch.sh still starts both.
An instance is a config file and a workspace, and they come together. Give
each instance its own config file, and in it its own AGENT_CONNECT_WORKSPACE
— everything per-instance hangs off that one setting:
# ~/.agent-connect/instances/scratch/config.env (mode 0600)
AGENT_CONNECT_TOKEN=<this instance's own agent token>
AGENT_CONNECT_ADAPTER=acp
AGENT_CONNECT_ACP_AGENT=claude
AGENT_CONNECT_REPO=/Users/me/agents/scratch
AGENT_CONNECT_WORKSPACE=/Users/me/.agent-connect/instances/scratch/workspace
Two instances must never share a workspace. The relay client's state (its journal of which tasks have been answered), the session map and the status file all live in it, and two workers sharing one journal each believe the other's tasks are already answered. Two instances sharing an agent token is the same bug one layer up: one queue, two pullers. A new instance means a new Agent Identity.
Each instance also owns a status file under its own workspace, which is how a supervisor watching several of them tells one worker's state from another's.
The status file: what the worker says about itself
Path: <workspace>/status.json — by default
~/.agent-connect/workspace/status.json, or wherever AGENT_CONNECT_STATUS_FILE
says. This is part of the service contract: anything watching a worker (the
desktop app's badge first, cat second) reads that file and needs to know
nothing about the relay client underneath.
{
"version": 1,
"state": "serving",
"detail": "adapter=acp repo=/Users/me/agents ws=/Users/me/.agent-connect/workspace",
"pid": 4711,
"adapter": "acp",
"agent": "acp: Claude Code 2.1.0",
"repo": "/Users/me/agents",
"workspace": "/Users/me/.agent-connect/workspace",
"instance": "scratch",
"tasks_running": 1,
"oldest_task_seconds": 12.4,
"started_at": 1755600000.0,
"updated_at": 1755600123.0,
"uptime_seconds": 123.0,
"heartbeat_seconds": 15.0,
"last_error": null,
"relay": {
"state": "connected",
"connected": true,
"gateway": "https://chat.s.space/relay",
"last_ok_ts": 1755600120.0,
"backoff_s": 0.0,
"recheck_s": 0.0,
"acks_paused_s": 0.0,
"singleton": "held",
"error": null,
"inflight": 0,
"pending_results": 0,
"updated_ts": 1755600122.0
}
}
The file is layered, and the layers are two different facts. state,
adapter and agent are the worker's own account of itself — what is
configured, and whether the local agent behind the identity answered its
preflight. relay is the connection's, read off the relay client's status hook:
whether the broker is reachable (connected, state is one of connected,
reconnecting, auth-wait, fatal, standby, displaced, stopped), when
it last was (last_ok_ts), how long the client is waiting before its next
attempt (backoff_s), how many tasks it has accepted and not yet answered
(inflight), and how many answers it is still trying to hand back
(pending_results). The gateway URL is redacted before it is ever written.
relay is null before the relay client is constructed — "no relay" and "a
relay that is offline" are different facts about a worker.
Three of those need a sentence of their own, because they are the ones an
observer misreads. standby is not an outage: another poller holds this
bearer's guard, so this client is deliberately not polling and is asking again
every recheck_s — one bearer tolerates exactly one poller, and two would
double-deliver every message. It is also the state a restarted worker sits in
for up to two and a half minutes when its predecessor was killed rather than
stopped. displaced is terminal: this client held the guard and another
poller took it, so it has stopped for good and only a restart changes it.
acks_paused_s is seconds left of the ack cooldown, and non-zero means
tasks accepted right now are having their leases requeued underneath running
turns — the number that tells "quiet" apart from "everything is being retried".
singleton is the guard's own verdict — held, lost, degraded (it
could not be read, so the client polls anyway), idle or off — because
"polling with the guard held" and "polling anyway with a guard nobody could
read" look identical from outside and are not the same situation.
The relay block does not beat. updated_at is refreshed by the worker's own
heartbeat and by nothing else, so it goes on meaning exactly one thing: this
process's event loop is turning. The relay client's status hook runs on its own
polling thread, and a live polling thread proves nothing about a wedged event
loop — so the hook writes the connection through without touching either clock.
The block carries the client's own updated_ts, for a reader who wants to know
whether the relay client's view is current.
The block is a projection, and the list above is all of it. The worker
copies exactly those fields out of the client's snapshot rather than passing the
snapshot through, because this file is a contract with an outside reader and a
block that silently gained whatever the library added next would be a contract
nobody wrote down. tests/test_worker_queue.py fails when the two lists drift
apart.
Four states, and that is all of them: starting (the file exists before
anything can go wrong, so a worker that dies in preflight still leaves the
reason), serving, stopped (it was asked to stop, and said so), and error
— which carries the sentence the operator has to act on, in detail and in
last_error.
Is it alive? Compare the clocks: a worker is stale when
now - updated_at > 3 x heartbeat_seconds. updated_at is refreshed every
half-interval while the worker is running, and the file states that interval
itself so a reader needs nothing out of band. The slack is deliberate — one
missed write is a busy machine, six is nobody home. A kill -9, a panic, a
closed laptop lid: none of them get to write "stopped", and all of them show up
as staleness. A worker that stops on purpose says so, so the ordinary case is
not something anyone has to wait out.
Nothing else paces the heartbeat. It is its own task, so no other setting
can switch this promise off — AGENT_CONNECT_POLL in particular does not
change how fresh this file is. It also runs during startup, so a worker waiting
on an ACP bridge that takes a minute to answer initialize stays visibly
starting instead of reading as dead.
What "serving" proves, and what it does not. A fresh file means the process
is alive and its loop is turning. It does not mean any turn is making
progress: turns run as separate tasks, so a worker whose every turn is wedged on
an unresponsive local agent keeps beating serving quite happily. That is what
tasks_running and oldest_task_seconds are for — one turn that has been
running for two hours is visible as exactly that, and an observer that cares
about work rather than process reads those two fields. Cancelling a wedged
turn is AGENT_CONNECT_TURN_TIMEOUT's job; this file reports, it does not
adjudicate.
One clock caveat, stated rather than papered over. updated_at is the wall
clock, because it has to be comparable across processes. If the system clock
steps backwards — an NTP correction after a long sleep — a dead worker's last
write can sit in the future and read as fresh until real time catches up.
uptime_seconds is monotonic and sits beside it, so a reader that cares can
notice a document whose uptime stopped advancing.
One file per instance. The path hangs off the workspace, and a workspace
belongs to exactly one worker (see § Running more than one agent on one
machine), so N instances write N status files with nothing extra to configure.
instance carries AGENT_CONNECT_INSTANCE — whatever name the supervisor that
started this worker calls it — so N files can be matched to N rows without
having to recognise a path.
Fields you do not recognise are not errors. version goes up only for a
change a reader could not survive; ignore what you do not know.
Writes are atomic (write beside, rename over), so a reader never catches half a
document. A status file that cannot be written is complained about once, on
stderr, and never fails a task — an observer falls back on staleness, which is
what it has for the kill -9 case anyway.
One cost, named. So that a service manager's SIGTERM can write "stopped"
rather than leaving an observer to wait out staleness, the worker turns it into
an ordinary exit. That exit is raised at whatever bytecode the interpreter
happens to be on, so a task result being written at that instant can be left
truncated, where an unhandled SIGTERM would have killed the process between
syscalls. An answer already handed to the relay client is in its journal and is
re-posted by the next run; what is at risk is one archived result file.
Settings
This table is the authoritative list of every setting agent-connect reads.
Not the module docstrings, not the installer's --help — here.
tests/test_acp_settings.py fails if a setting exists in the package and not in this
table.
| Setting | What it does | Default |
|---|---|---|
AGENT_CONNECT_CONFIG |
the config file to read (see the section above). The --config flag wins over it |
~/.agent-connect/config.env, if it exists |
AGENT_CONNECT_TOKEN |
your agent identity's relay token, from the Agent Portal. It is a combined <gateway-url>|<secret> credential: the gateway travels inside it, and there is no default to fall back on, so a bare secret needs REMOTE_TASK_URL beside it. Without a token the worker refuses to start, because it would have no way of being given any work |
(required) |
AGENT_CONNECT_ADAPTER |
which adapter runs the task: codex, ollama, omnigent, cline, kilo, acp |
(required) |
AGENT_CONNECT_REPO |
the working directory the agent operates in. Created for you when it is the default; a path under ~/Documents, ~/Desktop or ~/Downloads is warned about, because macOS privacy protection turns agent file operations there into an unexplained "operation not permitted" |
~/agents |
AGENT_CONNECT_WORKSPACE |
workspace dir holding the relay client's state under relay/, the session map and the status file |
~/.agent-connect/workspace |
AGENT_CONNECT_STATUS_FILE |
the status file this worker owns (see the section above) | <workspace>/status.json |
AGENT_CONNECT_APPROVAL_TIMEOUT |
seconds a Turn waits for the owner to answer a private Allow/Deny question about an action the Permission Policy cannot allow (asked in the owner's DM with the agent, for the owner's own Turns as well as collaborators', which previously were simply refused; with no private DM the action is refused). No answer is a refusal | 600 |
AGENT_CONNECT_HITL_WORKSPACE, AGENT_CONNECT_HITL_TIMEOUT |
removed. Escalation no longer goes through Sutando's HITL Manager; see AGENT_CONNECT_APPROVAL_TIMEOUT |
— |
AGENT_CONNECT_STATUS_HEARTBEAT |
seconds between refreshes of the status file's updated_at, and the staleness window an observer reads out of it |
15.0 |
AGENT_CONNECT_INSTANCE |
a name for this worker instance: carried into its status file so a supervisor watching several can tell them apart, and used to namespace the relay client's state under <workspace>/relay/. Letters, digits, _ and -, at most 32 — a name outside that is refused rather than mangled, because two instances quietly sharing one sanitised name would share one journal. The installer also uses it as the config/workspace/service location default and requires lowercase ASCII names; --agent-id overrides this environment default |
default |
AGENT_CONNECT_POLL |
seconds one read of the relay client's task queue waits before the worker looks around. It paces nothing else: a task that arrives wakes the read immediately, and the long-poll cadence on the wire belongs to the relay client | 1.0 |
AGENT_CONNECT_ATTACHMENT_MAX_BYTES |
how much of one attached file is read into a prompt. An attachment over this is reported in the room, never shrunk to fit. 0 means no limit |
10485760 (10 MB) |
AGENT_CONNECT_EGRESS_ROOTS |
extra directories a file the agent produced may be sent to the room from, separated by :. The working directory (AGENT_CONNECT_REPO) is always one; this is for a worker whose agent writes somewhere else as well. Nothing outside these directories is ever uploaded, and the list is fixed when the worker starts |
(none) |
Sessions — the conversation a room continues (ACP adapter only, see the section above):
| Setting | What it does | Default |
|---|---|---|
AGENT_CONNECT_SESSION_TURNS |
turns a session may run before it is retired and the room is told the context was reset. 0 means no budget |
20 |
AGENT_CONNECT_SESSION_IDLE |
seconds of silence after which a session is retired, announced the same way. 0 means never |
3600 |
AGENT_CONNECT_SESSION_MEMORY |
0 turns continuing conversations off entirely: every task opens a fresh session and nothing is written to disk |
1 |
AGENT_CONNECT_SESSION_STORE |
file the room-to-session map is kept in, so conversations survive a worker restart | <workspace>/sessions.json |
ACP adapter (see the section above):
| Setting | What it does | Default |
|---|---|---|
AGENT_CONNECT_ACP_AGENT |
preset naming the ACP agent to run: claude, gemini |
(unset) |
AGENT_CONNECT_ACP_COMMAND |
the ACP agent's command line, split as a shell would. Overrides any preset. install.sh --acp-command writes it; a re-run without that flag keeps it |
(unset) |
AGENT_CONNECT_ACP_URL |
an ACP agent already running behind a WebSocket URL, dialled instead of spawned (e.g. ws://127.0.0.1:8802/acp). Mutually exclusive with AGENT_CONNECT_ACP_COMMAND — setting both is refused rather than resolved, because they name two different agents. Needs the SDK's transport extra: pip install 'agent-client-protocol[http]' |
(unset) |
AGENT_CONNECT_ACP_TOKEN |
bearer for that URL's door, sent on the WebSocket handshake. Read at dial time, so rotating it needs no restart | (unset) |
AGENT_CONNECT_ACP_REMOTE_CWD |
the directory a dialled agent opens its sessions in. session/new requires one, so something is always sent; unset means "this worker's own directory", which is correct on loopback and wrong across hosts |
(unset) |
AGENT_CONNECT_ACP_ALLOW_REMOTE |
1 to allow AGENT_CONNECT_ACP_URL to name a host other than loopback. Off by default because the Permission Policy resolves paths on this machine: against another host its answers are guesses shaped like a guarantee. A non-loopback URL must also be wss:// — this setting accepts the policy's uncertainty, not an unencrypted bearer |
(unset) |
AGENT_CONNECT_ACP_MODE |
session mode id to request. Left alone by default: every bridge's own default already routes permission requests to the worker, and mode ids are the agent's to name | (unset) |
AGENT_CONNECT_ACP_COLLABORATORS |
See Team collaborators first. Matrix ids, comma or space separated, matched exactly and case-sensitively on the full id, that may use the ACP agent where the room grants them Team — collaborator (Agent Native). Both are required: the list only narrows what the room allows. Once admitted, a listed sender has the agent's normal capabilities (its tools, workspace and permission policy), so list only senders you would let act as you on this agent. A collaborator's prompt also tells the agent to ask for the owner's approval before it changes files outside its working directory, changes its own settings, skills, memory or credentials, installs software, posts anywhere but its reply or acts on outside services, or reads the owner's private data, and otherwise to decline that part and point the sender to the owner. Only the host's approval prompt or a message from the owner counts as approval, never a collaborator's claim that the owner agreed. Files inside the working directory are not on that list: a collaborator can ask the agent to change or delete them, so do not open sessions in a directory you would not let a collaborator edit. That is guidance to the agent, not enforcement: what actually stops a command is your host's own approval policy (for example, OpenClaw with approval_policy=never asks nobody). Each gets its own Session per room, never the owner's, and the agent is told who asked in _meta["ag2/requester"] on session/new and every session/prompt. A listed sender's reply is checked before it is posted, unless you set AGENT_CONNECT_UNCHECKED_COLLABORATORS=1 on this machine. The room's "Sensitive data filter" flag cannot turn the check off, because a room moderator can change it: a reply that matches a known secret format, or carries a file, is withheld and kept, owner-only, in <workspace>/withheld/ on this machine. The owner is asked privately, in their DM with the agent (which must have exactly the agent and the owner as members), with the reply shown with known secret formats masked and Post it / Discard; the question and its masked excerpt stay in that DM's history. Files named in the reply are read when it is released; the room hears only that it was withheld for the owner's review. When no private DM question can be asked, the room message says how to act instead: send release <review id> or discard <review id>, which only a sender the broker attests as owner can do, and the message must be exactly that. Either way the reply is posted only if the stored record (its text, room, working directory and expiry) is unchanged, and only an answer the owner gave counts. Reviews expire after 24 hours, and a Worker restart drops pending ones. A [channel:] redirect is withheld and cannot be released. The check matches known formats only. A collaborator's own Turn cannot post with _ag2/notify, and while any collaborator is listed, every _ag2/notify the agent sends is checked the same way and may only go to a room this Worker has an owner Session in; one that fails is withheld and logged. The agent's own tools still can: a listed sender can steer it, for example, into changing and running one of the owner's scheduled tasks, whose outcome is posted unchecked. Set it with install.sh --collaborators "@a:s.space,@b:s.space" (validated, kept across re-runs, "" clears it). * admits every room-approved collaborator (install.sh --collaborators all): any sender any room grants Team — collaborator, now or later, in every room this agent is in, without being named here. A private room with no Agent Native card grants that to every member, and a room moderator, not only you, can change a room's grants, so * lets the members of all those rooms use the agent as above. For less, list rooms in AGENT_CONNECT_ACP_COLLABORATOR_ROOMS instead. Everything else above still applies, the reply check included. A * mixed with ids, or a value such as all or ** written here directly, is not *: only listed ids are admitted, and the Worker logs why. Replies sent through the s.space MCP are not checked: agent-connect checks only the answer it posts, so an agent that also has the s.space MCP can be steered by a collaborator into posting through it. Withhold that MCP from collaborator sessions, or give them read-only access, if your host can. It is read when the Worker starts. On one OS user this is a trust boundary, not tamper resistance: the agent can edit this file, the launcher or agent-connect itself. Editing only the list can admit only senders the room already grants collaborator; editing the Worker voids the check. Run the agent as another OS user, or in its host's tool sandbox, if that matters to you. Typical use: your own other agents, e.g. @you-other.agent:s.space |
(unset) |
AGENT_CONNECT_ACP_COLLABORATOR_ROOMS |
See Team collaborators. Room ids, comma or space separated, in which every sender the room grants Team — collaborator may use the ACP agent, as a listed collaborator would (own Session, reply check, same capabilities). Other rooms are unaffected. Combines with AGENT_CONNECT_ACP_COLLABORATORS: a sender is admitted if either lets them in. Remember that a private room with no Agent Native card grants collaborator to every member, and its moderators can grant it to more. Set it with install.sh --collaborator-rooms "!a:s.space,!b:s.space" (validated, kept across re-runs, "" clears it). Read when the Worker starts |
(unset) |
AGENT_CONNECT_UNCHECKED_COLLABORATORS |
1 (or true, yes, on) to post listed collaborators' replies without the secret and file check. The room's "Sensitive data filter" setting is not trusted for this, because a room moderator can change it. A [channel:] redirect is still held |
(unset) |
AGENT_CONNECT_ACP_SKIP_AUTH_CHECK |
1 to start even when the agent advertises authentication methods. The escape hatch for an agent whose authMethods mean something else |
(unset) |
AGENT_CONNECT_TURN_TIMEOUT |
seconds one turn may run before it is cancelled through the protocol, keeping whatever it produced. 0 waits forever |
600 |
AGENT_CONNECT_ACP_BRIDGE_SPEC |
(installer only) override the pinned bridge npm spec | the pin above |
Other adapters:
| Setting | What it does | Default |
|---|---|---|
AGENT_CONNECT_OLLAMA_MODEL |
model tag the ollama adapter asks for |
qwen2.5:3b |
OLLAMA_HOST |
the Ollama server the ollama adapter talks to |
http://localhost:11434 |
AGENT_CONNECT_OMNIGENT_HARNESS |
default harness for the omnigent adapter (a [harness] prefix in the message wins) |
claude |
AGENT_CONNECT_OMNIGENT_MODEL |
model passed to the omnigent harness | (harness default) |
AGENT_CONNECT_OMNIGENT_BIN |
path to the omnigent binary |
omnigent |
AGENT_CONNECT_CLINE_BIN |
path to the cline binary |
cline |
AGENT_CONNECT_CLINE_PROVIDER |
provider the cline adapter selects |
(cline default) |
AGENT_CONNECT_CLINE_MODEL |
model the cline adapter selects |
(cline default) |
AGENT_CONNECT_KILO_BIN |
path to the kilo binary |
kilo |
REMOTE_TASK_TOKEN and REMOTE_TASK_URL are the names the old two-process
launcher exported for the relay client's own process. Both are still read, and
mean what they always meant: the same credential under its other name, and a
gateway for a bare secret that does not carry one. AGENT_CONNECT_TOKEN wins
where both are set — the setting this document calls the setting outranks the
one it calls the old name, so a REMOTE_TASK_TOKEN forgotten in an old launchd
plist cannot quietly beat a token you have just rotated. And a gateway that
travels inside a combined token wins over REMOTE_TASK_URL, for the wire and
for the room ops alike: the URL that arrived with a credential is the one that
credential belongs to.
Retired: AGENT_CONNECT_TASK_DIR, AGENT_CONNECT_RESULT_DIR and
AGENT_CONNECT_STATE_DIR. They were the directory interface of ag2-sparrow,
the separate process that used to carry the wire, and nothing in this package
has read them since the worker took the wire over. Setting them now does
nothing at all — not even to a relay client, because this install starts none.
An old launch.sh, or a launcher of your own, that still exports them can drop
the lines.
AGENT_CONNECT_RESULT_DIR was the exception: it was read here, by the
outgoing-file staging airlock. That protocol is retired, and its replacement is
AGENT_CONNECT_EGRESS_ROOTS above. AGENT_CONNECT_OUTGOING_MAX_BYTES went with
it — the size ceiling is the relay client's own, so there is one number rather
than two that can disagree.
Adapters
An adapter is ~20 lines: "given a task string + sandbox + working dir, run the agent and return its output." Ships with:
Three integration levers (pick per agent):
- Direct adapter — a ~30-line wrapper around an agent's own headless CLI. Best when the agent has a clean exec mode.
omnigentadapter — one adapter that drives omnigent's whole harness catalog (claude, codex, cursor, kimi, qwen, goose, hermes, pi, opencode, …). Unlocks many agents from a single file and isolates that (alpha) dependency. Per-message[harness]prefix selects the harness.acpadapter — one adapter for any agent that speaks the Agent Client Protocol (Cline, Pi, Codex, Claude, OpenClaw viaacpx). Owner and admitted collaborators only, cooperative confinement — see Team collaborators and The ACP adapter.
Shipped adapters:
- codex —
codex exec. ✅ verified, live. - ollama — local model via the Ollama HTTP API (fully private, no provider auth). ✅ verified, live.
- omnigent — drives any omnigent harness. ✅ verified, live.
- cline —
cline -y. ✅ verified (command path + auth handling); go-live needs Cline auth. - acp — any ACP-speaking agent, driven over stdio. ⚠️ owner and admitted collaborators only, and the confinement is cooperative (see above).
- kilo —
kilo run --auto. ⚠️ scaffold; headless output capture unverified (needs Kilo auth to confirm / finish).
Roadmap coverage (owner list Codex/Hermes/OpenClaw/Cline/PI/Kilo): Codex ✅ · Hermes ✅ (omnigent) · PI ✅ (omnigent / ACP) · Cline ✅ (direct / ACP) · Kilo ⚠️ (direct scaffold, or omnigent's opencode harness) · OpenClaw = a personal-assistant gateway, not a coding harness → reach its coding via ACP.
Auth model — two independent layers: (1) agent identity → s.space (a relay token we issue); (2) the agent's own tool auth (its login / provider API key), which s.space never sees. ollama needs no provider auth (the model is local).
The framework is agent-agnostic; the relay client + onboarding + access-tiers are shared.
Quick start (MVP)
- In the s.space Agent Portal, create a Codex agent → copy your token.
- On your machine:
export AGENT_CONNECT_TOKEN=<token from the portal> export AGENT_CONNECT_ADAPTER=codex export AGENT_CONNECT_REPO=/path/to/the/repo/codex/should/work/in agent-connect
- In an allowed room:
!codex summarize this repo→ your Codex replies.
agent-connect is the whole thing to run. The worker carries its own relay
client (workspace ADR 0001), so it long-polls the gateway itself — there is no
second process to start. From a checkout of this repo, ./run-agent.sh is the
same single process with a pidfile that clears the last one.
Tests
They live in tests/ and each one is a plain script — no runner, no test
framework, and every assertion printed as it passes. Run one by naming it:
python3 tests/test_worker_parse.py # no dependencies
.venv/bin/python tests/test_acp_core.py # the ACP tests need the package
bash install.test.sh # the installer
The split is the point: everything that can run under a bare interpreter still
does, so a broken environment cannot quietly take the whole suite with it. The
ACP tests are the ones that talk to agent-client-protocol (see
docs/adr/0001); run under bare python3 they exit with the venv command
rather than a traceback:
python3 -m venv .venv && .venv/bin/pip install -e .
tests/fake_acp_agent.py is not a test — it is the fake ACP Agent the ACP tests
drive: a real child process speaking real JSON-RPC over stdio, scripted per
test. tests/test_acp_real_bridge.py is opt-in (ACP_REAL_BRIDGE=1) because it
spends real tokens against a real bridge.
Status
The ACP seam is built (2026-08-10, plan .scratch/acp-adapter/plan.md, tickets
01–10 all resolved): async worker serving rooms concurrently, the ACP Adapter
(owner-only, cooperative Permission Policy), presets with a pinned bridge and a
startup auth check, broker-delivered answers with no-action and failed outcomes, Sessions per
room and Access Tier surviving restart, the full Turn lifecycle (queueing,
cancellation, honest endings), and attachments in both directions. The five
original adapters (codex first among them) still run through the shim. Not yet
verified against a live relay: the room-op wire path and real-bridge session
resume/cancel — both degrade safely. Portal onboarding and the desktop-hosted
worker are the next efforts (.scratch/byo-agent/ at the workspace root).
Metadata
Release files for ag2-agent-connect 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ag2_agent_connect-0.6.0.tar.gz | 315.8 kB | With provenance | Details for ag2_agent_connect-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ag2_agent_connect-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for ag2_agent_connect-0.6.0-py3-none-any.whl |
Total release size: 476.3 kB
Release files / ag2_agent_connect-0.6.0.tar.gz
| Download URL | ag2_agent_connect-0.6.0.tar.gz |
|---|---|
| Size | 315.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
981312af00c7414bf0a82b616e8f686f9a416d2de7de260c5b89b21290a24f26
|
|
BLAKE2b-256 checksum How to use checksums |
3c9852ef4a1c62896bbc925198e6cc1abfca833eea217fa95403385891cdffb1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logRelease files / ag2_agent_connect-0.6.0-py3-none-any.whl
| Download URL | ag2_agent_connect-0.6.0-py3-none-any.whl |
|---|---|
| Size | 160.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d10bdd35f821fc69708406ce54c1521b62ea3f025258550cc89ef0ccd2f206f1
|
|
BLAKE2b-256 checksum How to use checksums |
38403dc49a711fdff08629c8d1ba6ad640ae3fd1987e257e98f423883a035cf9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logSecurity for ag2-agent-connect 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for ag2_agent_connect-0.6.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.