Skip to content

fix(messaging): keep hosts receiving after a lease expiry or reconnect - #586

Merged
kevintseng merged 2 commits into
mainfrom
codex/rebuild-m6-messaging
Oct 5, 2026
Merged

kevintseng merged 2 commits into
mainfrom
codex/rebuild-m6-messaging

Conversation

@kevintseng

Copy link
Copy Markdown
Collaborator

Agent-to-agent messaging could stop working without anyone noticing. This fixes the cases a whole-tree review proved:

  • After a laptop sleep, a host stopped receiving messages for good. The router answered every heartbeat with stale_generation, the client ignored it, and the session stayed "connected" but unreachable. The client now registers again (waiting longer each time if the router keeps refusing).
  • A Codex app-server that was slow to open crashed the host (an unhandled socket error after a timeout); a null reply frame threw a TypeError. Both are handled.
  • A Codex session start that failed printed only a generic line. The real reason is now printed and logged; a managed Codex that dies while connecting fails the start instead of leaving a host that looks alive.
  • memesh-host-acp rejected every message after its router connection reconnected. It now checks the live generation. A rejected delivery is recorded under a code made from the error (acp_stale_generation_error), and an oversized message to a Claude host now reports native_message_too_large, as documented.
  • Retrying a send after a principal fallback delivered a second copy. The same idempotency key now returns the first message.
  • CLI: memesh message send --payload-stdin no longer garbles a multi-byte character split across writes, and subcommands refuse extra words (memesh remember Use OAuth with PKCE used to store only "Use").

Verified locally: npm run verify green for the final tree; each fix has a test that fails when the fix is reverted.

Refs #532, #541

- A host whose router lease expired (laptop sleep) now registers again
  instead of staying connected but unreachable; repeated refusals wait
  longer each time.
- A Codex app-server open timeout no longer crashes the host, and a null
  frame is a protocol error.
- A Codex session start that fails prints and logs its real reason; a
  managed Codex that dies while connecting fails the start instead of
  leaving a host that looks alive.
- memesh-host-acp keeps receiving messages after its router connection
  reconnects; a rejected delivery is recorded under a code made from the
  error, and an oversized message reports native_message_too_large.
- Retrying a send with the same idempotency key after a principal
  fallback returns that message instead of delivering a second copy.
- memesh message send --payload-stdin keeps a multi-byte character split
  across writes intact, and CLI subcommands refuse extra positional words
  instead of dropping them.
@kevintseng
kevintseng merged commit 3f3be4d into main Oct 5, 2026
12 checks 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.

1 participant