Skip to content

Bridge v2 agent_handshake_next dependency waits with bounded server-side waiting - #121

Merged
thetangstr merged 1 commit into
mainfrom
fix/v2-next-bounded-wait
Sep 17, 2026
Merged

thetangstr merged 1 commit into
mainfrom
fix/v2-next-bounded-wait

Conversation

@thetangstr

Copy link
Copy Markdown
Owner

Summary

  • agent_handshake_next now bridges ordinary dependency waits server-side: optional waitMs (default 12s, max 15s, 0 disables) threaded schema -> broker -> coordinator -> relay long-poll.
  • Wait loop re-evaluates after each relay slice, long-polling only for messages after the observed highestSeq cursor (never replays backlog / spins), clamps to remaining sessionDeadlineMs, and is bounded by MAX_NEXT_WAIT_POLLS.
  • Every dependency-wait body now carries retryAfterMs + nextAction; awaiting_counterpart, awaiting_proposal, awaiting_descriptor, awaiting_anchors, awaiting_certificate gained the missing nextAction.
  • Actionable/terminal responses (joinRequired, signing requests, registration/certificate localActions, errors) return immediately without waiting.
  • Relay getMessages accepts waitMs, clamped to 60s on the wire.

Test plan

  • mcp-server 452/452 (incl. new: funding->register, counterpart/proposal->sign_acceptance, certificate wait, timeout body, deadline clamp, immediate paths, waitMs validation, cursor long-poll, relay forwarding)
  • all workspaces 675/675
  • funded canary (held pending deploy)

Exact-SHA review: PASS on 8834593.

…ide waiting

Production canaries showed a public client (Codex) ending its turn after a
normal awaiting_funding/awaiting_counterpart response even though the body
asked for a retry. Model-managed polling is unreliable at this tool boundary,
so agent_handshake_next now holds a single call for a bounded waitMs (default
12s, max 15s, opt-out with 0), long-polling the relay for new messages after
the observed highestSeq cursor and re-evaluating until an actionable,
terminal, or deadline-bounded outcome. Every wait body now carries
retryAfterMs plus nextAction; awaiting_counterpart, awaiting_proposal,
awaiting_descriptor, awaiting_anchors, and awaiting_certificate gain the
missing nextAction. waitMs is threaded schema -> broker -> coordinator ->
relay, where it is clamped to 60s on the wire.

Constraint: must not exceed likely MCP client timeouts; 15s max stays well
under them while bridging funding-visibility and counterpart gaps.
Rejected: harness relaunch/resume as primary fix | certifies the harness,
not the public client/tool contract; local MCP proxy | new trust component.
Confidence: high
Scope-risk: narrow
Directive: keep waitMs clamped at or below 15s and never sleep past
sessionDeadlineMs; the cursor must always advance past observed highestSeq
or the poll replays the backlog and spins.
Tested: mcp-server 452/452 incl. funding-visibility->register, counterpart/
proposal->sign_acceptance, certificate wait, timeout body preservation,
deadline clamp, immediate actionable/terminal paths, waitMs validation,
cursor-cursor long-poll, relay waitMs forwarding; all workspaces 675/675.
Not-tested: live funded canary (held pending exact-SHA review + deploy).
@thetangstr
thetangstr merged commit 9f085e2 into main Sep 17, 2026
2 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