Skip to content

fix(client): keep control sessions alive - #530

Merged
jdchawla29 merged 1 commit into
mainfrom
chinmay/control-channel-keepalive
Aug 6, 2026
Merged

jdchawla29 merged 1 commit into
mainfrom
chinmay/control-channel-keepalive

Conversation

@ChinmayK0607

@ChinmayK0607 ChinmayK0607 commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • Keep HUD TCP control sessions active with a client-owned heartbeat every 120 seconds, reusing the existing hello(session_id) protocol.
  • Serialize control RPCs so heartbeat and grading replies cannot be consumed out of order.
  • Bound heartbeat replies to 5 seconds. Transport failures abort while the RPC lock is held; fully consumed HUD protocol errors only stop further heartbeats.
  • Remove runtime-provider flags and rollout-level keepalive orchestration.

Why

Long rollouts can leave the control connection idle between tasks.start and tasks.grade. The observed hosted failures resumed traffic after roughly 350 seconds and received a connection reset.

Connection liveness belongs to the client transport, independent of the runtime provider.

Validation

  • uv run --with='.[dev]' pytest -q — 961 passed, 9 deselected
  • uv run --with='.[dev]' ruff check .
  • uv run --with='.[dev]' ruff format --check .
  • uv run --with='.[dev]' pyright — 0 errors; existing optional-import warnings only

Note

Medium Risk
Changes core control-channel RPC behavior and long-session liveness for all connect() users; mistakes could break grading or leave connections in a bad state, but scope is localized to the client transport with new tests.

Overview
Keeps long-lived TCP control sessions from dying during idle gaps (e.g. between tasks.start and tasks.grade) by sending a 120s hello(session_id) heartbeat from connect(), with 5s reply timeouts.

Control RPC plumbing is tightened: _call runs under an asyncio.Lock, optional reply_timeout, reply id validation, and abort() on transport mismatches or non-protocol failures so heartbeat and grading traffic cannot steal each other’s frames.

Heartbeat protocol errors only stop further heartbeats; transport/timeouts cancel the owning connect() body so callers see the real failure. Tests cover serialization with a slow heartbeat error and interruption on transport failure.

Reviewed by Cursor Bugbot for commit a9fd7ee. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread hud/eval/run.py Resolved
Comment thread hud/eval/run.py Resolved
Comment thread hud/clients/client.py Resolved
Comment thread hud/clients/client.py Resolved
@jdchawla29
jdchawla29 force-pushed the chinmay/control-channel-keepalive branch from c26ce7c to 5ef4cd7 Compare August 6, 2026 06:13
@jdchawla29 jdchawla29 changed the title fix(eval): keep Modal control sessions alive fix(client): keep control sessions alive Aug 6, 2026

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5ef4cd7. Configure here.

Comment thread hud/clients/client.py Resolved
@jdchawla29
jdchawla29 force-pushed the chinmay/control-channel-keepalive branch from 5ef4cd7 to a9fd7ee Compare August 6, 2026 06:25
@jdchawla29
jdchawla29 merged commit 2394835 into main Aug 6, 2026
8 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.

2 participants