Repository navigation
feat(bots): bot chats keep their tools across an Orca restart and update - #51086
Conversation
…ep caller owner lookup in ACP
…eanup fails, keep locked callers, reattach before app-bound Codex starts, coalesce kept-file writes, dedupe front serving, drop pins
…callers through reattach, only bot callers force app-bound, unlock from botOf, bounded unlock retries, cancel front setup on close, serialize coalesced writes
…in so a locked keyring recovers, keep each kept caller in its own file, cap event streams per front so calls always get a pipe
…voked, locked callers retry in turn, each profile keeps its own grants, a reattached caller's earlier entry goes only once its run is placed, keep cleanup room through a front
…n the keychain, retire a carried caller when its run ends, retry a failed front serve on its own
… shared-tool caller
…leted chat's callers go, a failed handoff write keeps the earlier entry, one file per kept grant owner, revocations tracked only while seals run, stop serve retries for a gone daemon start
…p-alives never hold the daemon pipes cleanup's reserve needs
… memory, not sealed on disk The daemon start that keeps an agent holds its relay grants and shared-tool caller in memory for exactly as long as the agent's relay runs, received with the agent's spawn and handed back only on the app's authenticated serve. A bot's revoke drops them on every daemon start first. Removes the sealed grant and caller files, the keyring paths and their tests. The front's descriptors count against a budget.
…ler, a token's reach narrows for every token of its owner, refused front sockets are counted and capped, a launch given a front runs under its start or goes app-bound, one serve retry per daemon start, adopted tokens and callers go when their relays do
…t, so pooled, Pi and fallback launches keep the app's address; a kept relay's end drops its handed-back token and caller at once; the front's pipe cap is 128 so its descriptors stay under 400; grants indexed by owner and bots by id; a reconnect keeps its serve retry; startup listing retries on its own
…s, so none outlive a relay that never did; format
…launch's front pin; a relay end that races the serve reply still drops its grants; tool calls through a front wait only for that front's serve; the daemon token is read once per connection, bounded; refusal and revoke records are capped and retired; idle retries stop after a few
…hen the handler asked for keep-alive (an MCP SDK event stream), so it never holds a daemon pipe
…ent that drops an id-less JSON-RPC error fails the call at once and shows the message instead of waiting out its timeout
|
Review status for Since the previous status (
|
…s-survive-restart # Conflicts: # src/main/acp/session/acp-structured-acquire.ts
…hared-tool caller
|
Review status for Since the previous status (
A Claude bot chat's tool call, and a Codex bot chat's tool call after a restart: |
…rk, gate on relay requirements - Never end a newer daemon's unknown-integration relays at listing; they are kept for that Orca. - No disk work on the relay route unless a newer generation is held; its start ID is read once. - Connect a newer daemon only when a chat's run names it, so an unused one can still retire. - ProviderRelayInfo.requires: an app attaches only relays whose every requirement it serves; others stay kept and get the newer-Orca refusal. - Choose that refusal only when the newer daemon couldn't be connected; clear it with the run verdict.
…y, not on the relay route
… an unused newer daemon go - A relay of an integration this build can't reattach is kept-but-unusable: the update refusal. - A newer daemon that lists a relay but won't attach it gives the update refusal. - The run gate connects a newer daemon only for its own start; its client disconnects once no relay is bound, so the daemon can retire. - Launch listing doesn't wait on an unconnected newer daemon; its chats ask it themselves. - Drop an unrelated lockfile change.
Disconnecting a newer daemon's client when its last relay unbound ran before the quit hand-off's final acks and detach policy, and could cut another chat's listing or a delete's close. Drop it: only a newer daemon a chat here names is connected, and it stays connected until quit.
…eattached chat reads through Stopping it would end that chat's agent and drop its unread output; its terminals stay held until no attached agent reads through it.
… and stops a newer daemon The bound-relay check alone could race an attach during the stop's process inspection.
… are daemon work, so an idle check or idle shutdown never retires a daemon under them Once the front alone kept the daemon from retiring, its last call, pipe or grant going re-runs the idle check.
# Conflicts: # src/main/daemon/protocol/daemon-provider-relay-protocol.ts # src/main/daemon/providers/routing/daemon-newer-protocol-hold.ts # src/main/provider-relay/app-provider-relays.ts
[Medium impact] The latest changes appear safe to merge; no new blocking issue was found. SummaryBot chats can keep their tools across restarts by using a loopback address held by the daemon. The daemon keeps the agents’ grants in memory and returns them to the app when it reconnects.
|
…through a newer daemon's client, which can't serve the front
|
Review status for Since the previous status (
A Codex bot chat's tool call after a restart: |
…ts and callers when it disconnects, not only at the next tool launch
…ts and callers when it disconnects, not only at the next tool launch
|
Review status for Since the previous status (
|






ELI5
Before: when you quit or updated Orca, a bot's chat lost its tools. Its agent could keep running, but every tool call failed from then on, so Orca never let a bot's chat outlive the app.
After: on macOS and Linux, a bot's chat (and any chat using the MCP servers from Settings) keeps running through a restart, a crash or an update, when its agent is Claude, Codex running its own app-server, or an ACP agent that runs under the background service. While Orca is away, a tool call is told that Orca is restarting and to try again in a few seconds. Once Orca is back, tools with saved values work again at once. Tools that use Orca's own sign-in start a new session, which the agent does on its own. Nothing is written to disk and no keychain is needed, so this works on Linux without a keyring too.
Nothing changes on Windows, on remote hosts, or with an older background service: there, a bot's chat still ends with the app, as before. The same goes for Pi chats, Codex chats using shared app-servers or a custom command, and ACP agents with a sign-in step.
What Changed
toolRelayFront, new in daemon protocol 65 (so an update starts a fresh daemon that has it, while the older one keeps its agents): one loopback port, opened on first use, that lives as long as that daemon start. The daemon never connects to the app and never parses request bytes. For each connection it accepts, it announces an id on the app's authenticated stream. The app then opens its own connection to the daemon socket with a token-checkedtool-relayhello, and the daemon splices the two together. The app hands that socket to the relay's HTTP server in-process, so the existing Host, bearer, path and admission checks all still run.503,Retry-After: 5and a plain-text body that says Orca is restarting. Plain text, not a JSON-RPC error: the daemon never reads the request, so such an error could name no request id, and an MCP client drops an id-less error and waits out its own timeout. A plain-text error fails the call at once, with this message. The same answer goes out at once past 64 held connections or 128 live pipes, so the front's descriptors stay under 400. Past 64 connections already being answered, a new one is closed with no answer.DELETEalways get a pipe. Every connection through a front closes after its answer.relaySpawn.toolGrants). That daemon start holds it in memory, keyed by the agent's relay, from the moment its relay forms (before any I/O) until the relay ends; when it ends, the app serving that front hears so and drops the token and caller it took back. A kept ACP chat's shared-tool caller token travels the same way.toolRelayFrontServe, and recognizes those tokens again. When a terminal service is replaced, what the app took back from the old one goes with it. A deleted bot's grants are dropped then and there.toolRelayFrontRevoketo every daemon start; a start that doesn't answer can't bring it back, since adoption skips a revoked or deleted bot. Narrowing a bot's reach narrows every token it has.SessionMcpTools.appBoundis false, so Codex, Claude and ACP chats of bots relay like any other chat. A launch is pinned to its front's daemon start. One that lands on another start is refused with an ordinary "send again" error, and the next send takes the new start's front. One that still doesn't run under it (a spawn that fails, or shared servers turned on mid-launch) is refused the same way, and that chat's next launch uses the app's own address.Why
Bot chats were always app-bound because their relay port and token lived only in the app's memory. Re-binding the same port after a restart would let any local process take it while Orca is closed. A port held by Orca's own daemon for the life of the agents that use it can't be taken, and the daemon already holds every kept agent's environment, so holding its grant beside it adds no new exposure.
Linked Issue
N/A (internal design).
Visual Proof
N/A: no UI change. Behavior is covered in Testing.
Testing
tool-relayhello with a wrong token is refused before any request byte reaches it. An older daemon offers no front.Connection: close(even when the handler asked for keep-alive), and aDELETEafter them still gets through.basic_textsafe storage), with real Codex and Claude bot chats and a shared command server as the tool:503,Retry-After: 5, plain text,Connection: close. Calls succeeded once Orca was back, and the next user turn in each chat used the tool.401at once and still401after another restart. The other bot kept working.Connection: close, and Orca closes the socket right after.Performance
Up to three daemon requests per chat launch (open the front, a folder check on macOS, and a serve once per daemon connection), one token-file read per daemon connection, and one extra local socket per tool connection while a front is in use. Each tool call through a front uses its own connection. The daemon holds a few hundred bytes per kept agent. At startup the app serves fronts only when a daemon start reports an agent holding a grant.
Risk
Level: Medium. Adds a loopback listener owned by the daemon. It passes bytes only into connections the app authenticated, and only on macOS and Linux. The daemon now holds kept agents' relay tokens in memory, returned only to the app's authenticated connection. Revert is a plain revert; nothing is left on disk.
Known limits:
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance