Repository navigation
feat(rap-agent-mail): let agents message agents in other Infinity daemons - #195
Open
akainth015 wants to merge 4 commits into
Open
akainth015 wants to merge 4 commits into
akainth015 wants to merge 4 commits into
Conversation
…pawn a child thread While a thread waited on an active tool call, every synthetic event was deferred, including non-associative subscription events. Those never touch the parent's history: they only spawn a child thread at a spawn point that excludes the pending call. Deferring them held independent work hostage to an unrelated call (two agents waiting on answers from each other deadlocked) and lost it on restart, since the defer queue is in memory. * `is_deferrable_synthetic_event` now defers only associative subscription events, thread reports, and parent messages * Add `threaded_subscription_event_not_deferred_during_async_tool_wait`
…esumes it A session stopped while its thread driver stayed live (parked in `sleep_until_event_or_input`) got no new `Live` lifecycle transition when the user resumed it, so it stayed marked stopped and the router silently dropped every later tool result and subscription event for it. * `SessionManager::send_input` clears the root session's stopped flag for user text * Export `infinity_agent_core::system::is_user_text_input` * Add `user_input_restarts_session_stopped_while_live`
Command RAP servers run per session and stop whenever their session goes idle, so none can keep receiving events for idle sessions. A `toolset_command` entry can now declare `"lifetime": "daemon"`: * One shared process per command (`DaemonServers`), spawned in the daemon's state dir with `RAP_SERVER_LIFETIME=daemon` and `RAP_CALLBACK_URL` (the callback port changes on every daemon restart) * Booted at daemon start for user-level entries; `supervise` restarts it if it exits; session idles never stop it; migrations skip it * Its stdin is a pipe that hits EOF when the daemon dies, so it can exit instead of lingering as an orphan * Stopping, archiving, or migrating a session sends `/close_thread` for the session root to daemon-lifetime servers (in the background, booting them first) * `infinity rap install --daemon-lifetime`; re-installing keeps an entry's lifetime Also, for every command server: * `ensure_up` restarts a server whose process exited * Startup-line (60s) and manifest-fetch (30s) timeouts, so a hung server cannot hold its boot lock forever * Thread lifecycle notifications look up server URLs when sent (`RapNotifier::new_live`), so a restarted server is still reached BREAKING CHANGE: `ToolSetConfig::ToolsetCommand` has a new `lifetime` field. BREAKING CHANGE: `ToolsConfig::add_installed_command` takes a `ServerLifetime`. BREAKING CHANGE: `SessionRapManager::new` takes a `DaemonServers`. BREAKING CHANGE: `ManagedRapServer::current_base_url` is no longer async. BREAKING CHANGE: `infinity_agent_cli::install::InstallArgs` has a new `lifetime` field.
Deploying infinity with
|
| Latest commit: |
cb7781a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://bb1b1723.infinity-dc7.pages.dev |
| Branch Preview URL: | https://pr-agent-mail.infinity-dc7.pages.dev |
…mons A new daemon-lifetime RAP server. Each daemon runs one mailbox; agents get: * `open_inbox`: a subscription that makes the thread reachable as `host/name`; each message is handled in its own child thread (default) or inline * `list_agents`: open inboxes on this host and every linked host * `send_message`: one-way message * `ask_agent`: a question whose tool call stays pending until the recipient calls `reply` * `reply`: answer a received question Mailboxes dial the peers in `~/.infinity/remotes.json` by forwarding a Unix socket over SSH; each link carries traffic both ways, so a host that cannot dial back (cloud desktop to laptop) still sends and receives. Messages wait in a durable outbox until acknowledged, are re-sent on reconnect and every minute, and receivers deduplicate them. Also: * Interrupting a waiting `ask_agent` withdraws the question; a stopped, archived, or migrated session closes its inboxes and fails the questions they had not answered * Stable host IDs and announced-name aliases, so hosts that dial each other under different names match up * Per-session rate limits, inbound validation, ping heartbeats, orphaned SSH tunnel cleanup, and a stdin lifeline to its daemon * Docs: `docs/docs/infinity-code/agent-mail.md` * Added to the release crate lists and THIRD-PARTY
akainth015
force-pushed
the
pr/agent-mail
branch
from
November 20, 2026 13:21
64096c2 to
cb7781a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Agents can now message agents in other Infinity daemons: across the hosts in
~/.infinity/remotes.json, or between daemons on one machine. The work comes as a new daemon-lifetime RAP server,rap-agent-mail, plus the daemon and runtime support it needs.sequenceDiagram participant LA as laptop agent participant LM as laptop mailbox participant CM as devbox mailbox participant CC as devbox child thread LM->>CM: ssh -L forward of its peer socket (only the laptop dials) LA->>LM: ask_agent(devbox/reviewer) LM->>CM: ask (durable outbox until acked) CM->>CC: subscription event → child thread CC->>CM: reply(message_id) CM-->>LM: reply over the same link LM->>LA: tool resultCommits
The commits are split for review; each builds on the previous one.
fix(infinity-agent-core): don't defer subscription events that only spawn a child thread. While a thread waited on an active tool call, every synthetic event was deferred, non-associative subscription events included. Those never touch the parent's history: they only spawn a child at a spawn point that excludes the pending call. Deferring them meant two agents asking each other questions deadlocked, and the in-memory defer queue lost them on restart. Associative events, thread reports, and parent messages are still deferred. A regression test is included. The Lambda runtime (NoDeferral) is unaffected.fix(infinity-daemon): clear a session's stopped flag when user text resumes it. If a session was stopped while its driver stayed live (parked insleep_until_event_or_input), resuming it produced noLivetransition. The session stayed marked stopped, and the router silently dropped every later tool result and event for it. I found this on real hosts; a regression test is included.feat(infinity-daemon)!: daemon-lifetime RAP servers. Atoolset_commandentry with"lifetime": "daemon"(written byinfinity rap install --daemon-lifetime) behaves as follows:~/.infinity, withRAP_SERVER_LIFETIME=daemonandRAP_CALLBACK_URLset./close_threadfor the session root.This commit also makes three changes that apply to every command server:
RapNotifier::new_livelooks up server URLs when it sends, so a restarted server is still reached.It has breaking API changes (footers in the commit).
feat(rap-agent-mail): the mailbox. It provides five tools:open_inbox, a subscription delivering each message to a per-message child thread (default) or inlinelist_agentssend_messageask_agent, whose call stays pending untilreplyreplyIt also includes:
docs/docs/infinity-code/agent-mail.md.Testing
cargo test -p rap-agent-mail(11 end-to-end tests: real mailboxes linked over Unix sockets, with RAP callbacks captured by a real callback server). Alsoinfinity-daemon,infinity-agent-coreandrap-client, plus workspace-widecargo clippy --all-targets -D warningsandcargo fmt --check.HOMEand real Bedrock agents:ask_agentresultkill -9kill -9Seven
infinity-agent-cliTUI snapshot tests fail locally (tui_reflow_snapshots,tui_submit_wrap_snapshots). They fail the same way onmain(e1a3e4b), so they're unrelated to this PR.Known limitations (documented)
127.0.0.1. It isn't meant for machines shared with other users.