Skip to content

Add durable cross-device agent messaging - #102

Merged
cyzus merged 2 commits into
mainfrom
agent/cross-device-agent-inbox
Aug 10, 2026
Merged

Add durable cross-device agent messaging#102
cyzus merged 2 commits into
mainfrom
agent/cross-device-agent-inbox

Conversation

@cyzus

@cyzus cyzus commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • reuse the existing Devices control-grant and Suzent HTTP channel as the cross-backend Agent transport
  • expose paired backends through agent_list as stable peer:<peer_id> addresses
  • route agent_send through the existing durable message table with a suzent_peer transport, preserving the same lease, retry, idempotency, and terminal-state machinery as local delivery
  • add a small PeerAgentTransport adapter shared by send, read, stop, and the inbox dispatcher
  • add POST /channels/suzent/inbox, which acknowledges only after the receiver commits the message to its local durable inbox
  • add peer-scoped session read and stop endpoints for agent_read and agent_stop
  • bind every authenticated caller to its own suzent:<device_id> namespace so a peer cannot select, inspect, or stop arbitrary local chats
  • keep remote delivery retryable for offline devices with bounded exponential backoff and receiver-side idempotent ACKs
  • preserve remote Agent IDs across LAN/Tailscale address changes by carrying the existing installation node_identity into the peer store
  • share transcript bounding and the process-wide peer store instead of duplicating queue, HTTP-auth, or transcript logic

Why

PR #101 added the local durable Agent inbox. Suzent already had device discovery, pairing, scoped peer tokens, reachability, and an agent-to-agent channel, so a separate relay stack would duplicate those responsibilities. This PR bridges the existing Nodes transport to the durable inbox and keeps all retry/state transitions in one queue implementation.

Security

  • all new remote routes require the existing agent-scope device grant
  • identity comes from the verified bearer token, never from a request body
  • inbox/read/stop always target the authenticated peer's dedicated session
  • optional legacy streaming session names are normalized below the authenticated peer namespace
  • message IDs and content are bounded and receiver ACKs are validated before marking outbound delivery complete

Verification

  • uv run --no-sync pytest -m "not sandbox" -q — 983 passed
  • focused database, inbox, Nodes, routing, auth, and Agent tool tests — 100 passed
  • final focused regression after HTTP adapter hardening — 86 passed
  • npm test — 80 passed
  • npm run build — passed
  • uv run --no-sync pre-commit run --all-files — passed

@cyzus
cyzus marked this pull request as ready for review August 10, 2026 10:26
Copilot AI lite review requested due to automatic review settings August 10, 2026 10:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ecd77967a9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/suzent/routes/suzent_channel_routes.py Outdated
Comment thread src/suzent/tools/agent_lifecycle_tools.py
@cyzus
cyzus merged commit c4fec48 into main Aug 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants