Skip to content

feat(agent-relay): raise max clients to 128 and wire id_range_step#765

Open
appcypher wants to merge 5 commits into
mainfrom
appcypher/raise-agent-max-clients
Open

feat(agent-relay): raise max clients to 128 and wire id_range_step#765
appcypher wants to merge 5 commits into
mainfrom
appcypher/raise-agent-max-clients

Conversation

@appcypher
Copy link
Copy Markdown
Member

@appcypher appcypher commented May 20, 2026

TL;DR

Raise the agent relay's MAX_CLIENTS from 16 to 128 and have the relay tell each SDK its assigned correlation-ID range size during the handshake, so the SDK no longer has to hardcode it.

Description

  • MAX_CLIENTS in the relay goes from 16 to 128, giving each connected client about 33.5M correlation IDs.
  • Handshake bytes change from [id_offset: u32 BE][ready_frame] to [id_offset: u32 BE][id_range_step: u32 BE][ready_frame].
  • SDK now reads id_range_step off the wire and derives its allocation range from that, instead of duplicating u32::MAX / 16.
  • Fixes a latent divergence where the SDK would silently misroute frames if the relay's MAX_CLIENTS ever changed without a matching SDK patch.
  • New id_start field on AgentClient cleans up the wrap path so it no longer references the constant either.
  • Python, Node-TS, and Go SDKs are FFI bindings to this Rust client, so they need no changes.
  • Bumps the mcp and skills submodule pointers and a small README copy tweak (separate chore commit).

Test Plan

  • cargo check -p microsandbox-runtime -p microsandbox exits 0
  • cargo test -p microsandbox-runtime --lib passes
  • Boot a sandbox, connect with the Rust SDK, run an exec, confirm stdout/stderr/exit code arrive correctly
  • Connect 2+ SDK clients to the same sandbox in parallel, run execs on each, confirm responses route to the right client

@appcypher appcypher requested a review from toksdotdev as a code owner May 20, 2026 11:11
appcypher added 2 commits May 20, 2026 14:28
Raise relay MAX_CLIENTS from 16 to 128 and extend the handshake to
carry the per-client correlation ID range size on the wire, so the
SDK no longer needs to know MAX_CLIENTS.

Before, the SDK computed its assigned ID range with a hardcoded
`u32::MAX / 16` that mirrored the relay's `ID_RANGE_STEP`. The two
sides had no way to stay in sync: changing MAX_CLIENTS on the relay
without patching the SDK would make the SDK trespass into neighbor
slots' ID ranges, causing silent cross-client frame misrouting via
`client_slot = frame.id / ID_RANGE_STEP` in the ring reader.

Wire change: handshake bytes go from `[id_offset: u32 BE][ready_frame]`
to `[id_offset: u32 BE][id_range_step: u32 BE][ready_frame]`. The SDK
reads both values and derives `id_start = id_offset + 1` and
`id_max = id_offset + id_range_step` from what it was actually told.
A new `id_start` field on `AgentClient` replaces the recomputed wrap
boundary so the wrap path no longer references the constant either.

At MAX_CLIENTS = 128, each client gets `u32::MAX / 128 ≈ 33.5M`
correlation IDs per connection, with slot reset on reconnect — ample
headroom for any realistic SDK lifetime. Future changes to
MAX_CLIENTS are now a one-line edit in `relay.rs` with no SDK rebuild.

Python, Node-TS, and Go SDKs are FFI bindings to this Rust client and
require no separate update.
- Reword the tagline to "the easiest way to give your agent their own
  computer".
- Drop one extra `<br />` above the YC badge and add two below for
  consistent spacing.
@appcypher appcypher force-pushed the appcypher/raise-agent-max-clients branch from a22c246 to cb35737 Compare May 20, 2026 13:28
Send the client's assigned correlation ID range as explicit start and
exclusive end bounds during the relay handshake. This keeps the client
contract focused on the allocation it may use instead of exposing the
relay's range-step calculation.

Validate the range on the SDK side and reject client frames in the relay
when their IDs fall outside the assigned interval.
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