* Stop messaging conversations from holding an agent's queue A turn that no event ended held the agent's queue until OpenBot restarted, and status posts in Slack, Discord and Telegram stayed on "Working" or "Waiting" after a restart or a failed post. - Muse ends a turn whose turn/start failed after turn/started. - A provider exit ends the turns of that client that have no message left for the delivery recovery, such as a turn the CLI started. - The drain does not mark a turn active that already ended, and settles the messages that such a turn left running. - Messages of an unconfirmed turn/start that no turn took in 5 minutes end as interrupted, and the queue continues. - A question card in a messaging thread is refused: nobody there can answer it. - An approval that did not reach the platform is posted again. - Discord and Slack name lookups no longer hold the prompt deadline. - The delivery recovery tells the conversation that a request ended. - Status posts and Stop buttons are kept in a file. A connection that is connected again sends each last post that did not reach the platform, and stops the posts of requests that ended meanwhile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Handle kept deliveries in order for each route only Signal keeps the order of kept deliveries for each route (Slack team, Discord guild, Telegram chat). The host opened and handled them under one global permit. Thus a connection that could not start held back the kept deliveries of all other connections, and each of its deliveries waited 60 s for the transport. - signal-ingress: open kept deliveries one at a time, in send order. Then each delivery waits only for the earlier deliveries of its route. - messaging-service: the kept deliveries of one connection share one transport deadline for each socket. A connection that does not start costs one 60 s wait, not one wait for each event. Ack and 503 behavior do not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep a Telegram link for the host's next Signal socket A `/start <code>` link could land while the host's ingress socket connected again. Then no socket, or a socket that closed, held the chat, and Signal sent the linked update only once, live. The host dropped it, and the route ticket of its next socket did not name the chat. The chat did not show in OpenBot until the user linked it again. - Signal keeps the linked update, sealed and with `linked: true`, in the ingress queue for the host until a socket acknowledges it. A host with no queue key, or a Signal with no queue, gets the live frame as before. - Signal remembers each new link for the route ticket TTL, and routes the chat to a new socket of that host whose ticket does not name it. The route floor still applies. - `IngressQueue.keep` keeps an event for a known host and starts no host. `offline` uses the same code. - The Signal E2E check links a chat between two sockets of one host. No frame changes meaning. The Signal change needs its own deployment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Merge the release notes of the messaging stall fixes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fix the local review findings of the messaging stall fixes - A last post goes out once: a copy that a settle and a wait both queued stops when the post is no longer the current one. - The last post is saved before it is sent, so a restart still has the answer when the send failed. - A settle stops only posts from before the restart. The end of a request in this run comes as an activity, which can still be on its way. - A turn with no known requester does not count as told, so the delivery settle still tells the conversation. - The status file is read at once, before the activity listener, so no activity is lost while it loads. Posts of a removed connection are left out. - A failed edit is sent again as an edit. Only the last attempt posts anew, so a temporary error leaves no second "Working" post. - A new message waits at most 5 seconds for its author and place names. - The reason of an unstarted turn uses a catalog key. - interruptTurnsOf takes keepRecoverable in place of a copy of its loop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Name the kept Telegram link in the Signal store rules Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Do not send a failed answer again An answer goes out in parts. When a later part failed, the retry sent the parts that were on the platform already. Now a failed answer is not sent again: the status post gets the fixed failure notice, and the host keeps the answer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
OpenBot Remote
This directory holds our own control plane for WebRTC connections. The Remote API relays SDP and ICE. Team files, chats, commands and video never pass through the Remote API or Cloudflare. The exceptions are the OpenBot Slack app, the OpenBot Discord bot and the OpenBot Telegram bot: see Slack requests, Discord and Telegram updates.
Flow
- The app signs the user in through the Cloudflare API.
- Cloudflare D1 checks membership and creates a logical session.
- Cloudflare signs a short ES256 ticket. The ticket names the host, the user, the role, the protocol version and
authEpoch. - The client and the host open
WSS /v1/signal. Signal validates the ticket locally through JWKS. - Signal relays SDP and ICE and issues a
resume tokenalong with time-limited coturn credentials. - Chromium sets up WebRTC. The Team API uses the
rpc,eventsandfileschannels. - ICE picks either a direct
p2ppath orrelaythrough this coturn. Cloudflare is never on the data path.
Signal has no database. It stores no tokens, SDP, ICE, file names or message contents. Room and presence data exist only in process memory. The one exception is the queue of a hosted server that sleeps (see Sleeping hosted servers): Signal keeps a Slack, Discord or Telegram event for it in memory, sealed to the host's key so that Signal cannot read it, for at most 10 minutes.
A resume token is valid for 10 minutes. Signal keeps the issued token in a bounded in-memory cache.
A normal reconnect validates that token locally. After a Signal restart the cache is empty, so the first
reconnect for a given token makes one signed request to the control plane. The same request is needed once
the token has expired. The control plane checks the session, the membership and authEpoch. Signal then
issues a new token. Subsequent reconnects are local again. There are no heartbeats and no periodic refresh
through Cloudflare.
Ending a session and changing access both write a revocation event to a durable D1 outbox. The Worker tries to deliver it to Signal immediately. If Signal is unreachable, the Worker retries the delivery from cron. An ordinary reconnect still does not ask Cloudflare. Ended and expired sessions are removed after the 10-minute validation window.
Slack requests
The OpenBot Slack app sends the events and button presses of every workspace to one request URL,
https://signal.openbot.run/v1/slack/events. Signal checks Slack's signature with the app's signing
secret, answers Slack's url_verification challenge, and reads only the app ID (api_app_id), the
workspace ID, and the event's type, channel type, thread and bot ID (to know whether it addresses
OpenBot, not its text). SLACK_SIGNING_SECRET is a comma-separated list of <app ID>:<signing secret>,
because the production and development apps share Signal. A request must name the app whose secret
signed it, so one app's secret cannot reach the other app's hosts; a malformed value turns off only
the Slack route. Then Signal passes the exact request body to the ingress socket of the host that
the app and workspace are linked to, and returns the host's answer, or 503 when no host holds the workspace or the
host does not answer in 2.5 seconds. Slack then sends the request again. For a hosted server that
sleeps, Signal answers 200 instead (see Sleeping hosted servers).
An ingress socket names its workspaces with a Slack route ticket: an ES256 JWT with the audience
openbot-slack-route, signed by the Worker with SLACK_ROUTE_PRIVATE_JWK (key id
SLACK_ROUTE_KEY_ID) for the workspaces, each with its app, that the account service links to that
host. Its public key
must be in the ticket JWKS that Signal loads (REMOTE_TICKET_PUBLIC_JWKS on the Worker, or
REMOTE_TICKET_PUBLIC_KEYS here). Signal does not store or log the body. Without
SLACK_SIGNING_SECRET, the Slack route answers 503.
Discord
The OpenBot Discord bot is one bot for every guild that installs it. Signal holds its bot token
(DISCORD_BOT_TOKEN) and its application ID (DISCORD_APPLICATION_ID). Without both, or with a
malformed value, Discord is off: Signal logs one line without the value, keeps no Gateway
connection, and POST /v1/discord/api answers 503. The remote sessions and the Slack route keep
running.
Signal keeps the bot's Gateway connection with the intents Guilds, GuildMessages and
DirectMessages, and no privileged intent. Discord then gives the bot the text of a message only
when the message mentions the bot. From the Gateway, Signal reads:
- the names of the guilds, channels and threads, and which guild each channel is in;
- each guild message that mentions the bot and that a person wrote. Signal passes the message ID,
channel, author, text without the bot's mention, the replied message, the Discord CDN addresses of
the attachments and the time to the
ingresssocket of the host that the guild is linked to; - each press of an OpenBot button. Signal acknowledges it to Discord at once and passes it on;
- the removal of the bot from a guild, which ends that guild's connection on the host.
A direct message to the bot gets one fixed answer, at most once an hour for each user. Signal does not pass it on.
An ingress socket names its guilds with a Discord route ticket: an ES256 JWT with the audience
openbot-discord-route, signed by the Worker for the guilds that the account service links to that
host. Its public key must be in the ticket JWKS that Signal loads, as for the Slack route ticket. The
account service revokes a guild link through /internal/auth-events. After a start, Signal asks the
account service which links are current until every older ticket has expired.
A socket with a Discord route gets a discord-session token and the list of the guilds routed to it. The host sends it as the
bearer of its calls to POST /v1/discord/api: post, edit or delete a message, add or remove a
reaction, read the messages after one message, read a member or channel name, answer a button press,
and upload one file of at most 10 MB. Signal makes each call with the bot token, only in a guild that
is routed to that socket, and only in a channel of that guild. No post can ping anyone. The token is
valid while the socket is open.
So the answers and files of Discord conversations pass through Signal. Signal does not store them or log them, and it does not log a token or Discord's error text.
When the bot leaves a guild, Signal drops its route and asks the account service to unlink it
(/v2/remote/discord-route/removed). After the Gateway lists the bot's guilds, and every 30 minutes,
Signal sends the account service the guild IDs that the bot is in
(/v2/remote/discord-route/reconcile), and the account service unlinks each older link of another
guild. Signal sends nothing while a Gateway shard is closed, because the list can then miss a new
guild. So a link goes also when its host is off and the first unlink failed, or Signal restarted.
Telegram updates
One OpenBot bot serves every user, and only Signal has its token. TELEGRAM_BOT_TOKENS is a
comma-separated list of bot tokens (<bot ID>:<secret>), because the production and development
bots share Signal. TELEGRAM_WEBHOOK_SECRET (at least 32 bytes) is required with them: the webhook
secret of each bot is the base64url HMAC-SHA256 of telegram-webhook:<bot ID> with it. A malformed
value turns off only Telegram. With TELEGRAM_WEBHOOK_ORIGIN, Signal sets the webhook of each bot to
<origin>/v1/telegram/updates/<bot ID> when it starts; a failure is logged and Signal runs on.
Telegram posts each update to /v1/telegram/updates/<bot ID>. Signal checks the secret header,
reads only the chat ID, the callback query ID and a /start <code> link code, and passes the exact
body to the ingress socket of the chat's host. A link code makes Signal ask the account service to
link the chat (/v2/remote/telegram-route/link), and routes the chat to that host at once. Signal
answers 200 to each signed update, also when no host holds the chat: Telegram holds back the bot's
other updates while one fails.
An ingress socket names its chats with a Telegram route ticket: an ES256 JWT with the audience
openbot-telegram-route, signed with the key of the Slack route ticket. When ready names the
telegram capability, the host calls the Bot API through the socket (telegram-call). Signal
accepts only the methods and parameters of TelegramCallParams, only for the chats routed to that
socket, and returns only the reduced result. A host downloads a file from /v1/telegram/files/<token>
and posts a document to /v1/telegram/uploads/<token>. These tokens are signed, expire after two
minutes, and an upload token works once. Signal does not store or log an update or a file, except
for the sealed queue of a hosted server that sleeps.
Sleeping hosted servers
All messaging platforms share one path (src/ingress-queue.ts). For an event whose route has no
ingress socket, Signal asks the account service (/v2/remote/route-wake, signed), at most once a
minute for each route. An event that addresses OpenBot starts a hosted server that sleeps. Signal
then keeps the event's delivery frame, sealed with the host's queue key (queueKey in the ingress
hello) and the host ID, for at most 10 minutes, 64 events and 192 KB for each host. When the host's
socket holds the route again, Signal sends each kept event in order as queued-delivery, and keeps it
until the host sends queued-delivery-ack. While a host has kept events, Signal asks for its start
again once a minute, because a start can fail after the account service answered. A host that
sent no key gets nothing kept. A restart of Signal loses the queue and the keys: until a sleeping
host connects again, its events start it but are not kept. Signal remembers at most 100,000 keys
and 100,000 route answers, and drops the oldest first. Signal names the
ingress-queue capability in ready only when the account service answered /v2/remote/route-wake
when Signal started: only then does a hosted server with a live connection sleep. Deploy the account
service before Signal.
Production requirements
- Linux with Docker Engine and Docker Compose.
- A static public IPv4 address.
signal.openbot.runandturn.openbot.runrecords in DNS only mode.- Open ports TCP 443, TCP/UDP 3478, TCP 5349 and UDP 49152-65535.
- A Cloudflare token scoped to DNS edit for the
openbot.runzone.
The signal.openbot.run and turn.openbot.run records must be in DNS only mode. Do not enable the
Cloudflare proxy for them. api.openbot.run stays a Cloudflare Worker.
If you already run a reverse proxy on port 443, set REMOTE_SIGNAL_BIND_ADDRESS=127.0.0.1,
REMOTE_SIGNAL_PUBLIC_PORT=8081, REMOTE_SIGNAL_PORT=8081 and REMOTE_TLS_DISABLED=true. The reverse proxy
must terminate TLS and forward the WebSocket to http://127.0.0.1:8081. Also set
REMOTE_TRUST_PROXY=true so the IP limits use the client address from X-Forwarded-For.
The configuration in nginx/signal.openbot.run.conf uses the certificate from the ACME volume. Install
openbot-remote-nginx-reload.path and openbot-remote-nginx-reload.service into /etc/systemd/system/ as
well. The unit reloads Nginx after the certificate is renewed:
sudo cp remote/nginx/openbot-remote-nginx-reload.* /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now openbot-remote-nginx-reload.path
Production secrets are stored in the tracked .env.production file as encrypted Dotenvx values.
The private decryption key lives only in the ignored remote/.env.keys file. Do not pass the encrypted
file straight to docker compose --env-file, because Compose will not decrypt the values.
The remote:* scripts run Compose through Dotenvx and decrypt the values only in process memory.
The --overload option keeps empty host environment variables from overriding the decrypted values.
The scripts use remote/bin/dotenvx. The wrapper picks the pinned Node from the application runtime if the
system Node is too old.
Validate the environment and start the services:
bun run remote:env:validate
bun run remote:up
bun run remote:check
Updating Signal may close the WebSocket. An active WebRTC connection stays up. remote:update puts coturn
into drain and waits for the allocations to finish. A single coturn instance is no protection against machine
failure. Forcing a coturn restart ends active relay sessions. The client performs an ICE restart and resumes
a file transfer from the last acknowledged offset once the service is back.
Current hosts advertise multiplex: true and support independent device sessions at the same time.
Reconnecting one session replaces only that session's Signal socket. Disconnecting or revoking one device
must not end another device's session. Legacy hosts that omit multiplex keep the one-client limit:
a second session receives host_busy without interrupting the first.
REMOTE_MAX_CONNECTIONS_PER_USER (default 32) limits the authenticated client Signal sockets of one
account. Each open desktop, phone, or browser keeps a socket for each saved host. A reconnect of the
same session does not count its old socket. Host sockets do not count, and the limit never refuses a
host. A host hello moves the clients of the older sockets of the same host to the new socket. The older
sockets stay open; when the new socket closes, the last remaining one takes the clients. A host keeps at
most 4 sockets: a fifth hello closes the oldest with code 1013, and that host can connect again. Change the value
on the Signal server: a desktop environment does not change it.
This also applies when the old client socket waits for its host to reconnect. Token signing finishes
before Signal admits the new socket, so concurrent reconnects do not hold extra account slots.
Production deployments keep /opt/openbot/remote/.env.production. A value in that file overrides
the default, even when a release changes the repository's environment file. Check the running
container's effective limit after a configuration change and Signal restart.
See the issue #325 deployment procedure for the production evidence, a Signal-only update, rollback commands, and the required desktop/mobile checks.
To run Signal with your own account service, see Self-hosted remote access.