Skip to content

fix(reliability): bound three unbounded waits that could hang the CLI#151

Open
tiantt wants to merge 1 commit into
mainfrom
fix/reliability-unbounded-waits
Open

fix(reliability): bound three unbounded waits that could hang the CLI#151
tiantt wants to merge 1 commit into
mainfrom
fix/reliability-unbounded-waits

Conversation

@tiantt

@tiantt tiantt commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Three status/connection waits could block the CLI indefinitely when a backend stalls or silently dies:

  • cr.py _create_instance: while True status poll had no deadline; a CR instance stuck in "Creating" hung the CLI forever. Add a monotonic-clock deadline that raises TimeoutError.
  • ve_agentkit.py _wait_for_runtime_status_multiple: timeout=None made if timeout and elapsed > timeout dead code, so the poll never timed out. Fall back to a bounded poll timeout when None.
  • cli_exec.py sandbox terminal: websocket run_forever() had no ping_interval/ping_timeout, so a dead peer left the session wedged with only Ctrl-C as an exit. Enable keepalive pings.

All three bounds are env-tunable via a single source of truth in http_defaults.py (AGENTKIT_POLL_TIMEOUT / AGENTKIT_WS_PING_INTERVAL / AGENTKIT_WS_PING_TIMEOUT), matching the existing http_timeout idiom.

Adds offline regression tests covering each bound.

Three status/connection waits could block the CLI indefinitely when a
backend stalls or silently dies:

- cr.py `_create_instance`: `while True` status poll had no deadline; a
  CR instance stuck in "Creating" hung the CLI forever. Add a
  monotonic-clock deadline that raises TimeoutError.
- ve_agentkit.py `_wait_for_runtime_status_multiple`: `timeout=None`
  made `if timeout and elapsed > timeout` dead code, so the poll never
  timed out. Fall back to a bounded poll timeout when None.
- cli_exec.py sandbox terminal: `websocket run_forever()` had no
  ping_interval/ping_timeout, so a dead peer left the session wedged
  with only Ctrl-C as an exit. Enable keepalive pings.

All three bounds are env-tunable via a single source of truth in
http_defaults.py (AGENTKIT_POLL_TIMEOUT / AGENTKIT_WS_PING_INTERVAL /
AGENTKIT_WS_PING_TIMEOUT), matching the existing http_timeout idiom.

Adds offline regression tests covering each bound.
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