Skip to content

fix(runtime): time out host_request when no host replies - #1233

Open
Electricitysheep wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
Electricitysheep:fix/host-request-timeout
Open

fix(runtime): time out host_request when no host replies#1233
Electricitysheep wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
Electricitysheep:fix/host-request-timeout

Conversation

@Electricitysheep

@Electricitysheep Electricitysheep commented Aug 11, 2026

Copy link
Copy Markdown

Summary

host_request() awaits a Jupyter comm reply that never arrives when the module runs outside a running Prime Agent session (e.g. a bare kernel venv, or a test harness without a host). It hangs forever — no timeout, no error.

This is exactly the trap encountered while testing MCP integrations: importing test_mcp and calling list_tools() from a standalone kernel venv blocks indefinitely because McpIntegration._resolve_config() calls host_request("mcp.config", ...) and nothing replies.

Changes

prime-agent-runtime/src/rlm/__init__.py:

  • Added HOST_REQUEST_TIMEOUT_SECONDS = 30.
  • Wrapped the pending future in asyncio.wait_for(...); on timeout, cancel the future, close the comm, and raise a RuntimeError that explains the request requires a running Prime Agent session (instead of hanging).

prime-agent-runtime/test/test_host_request_timeout.py (new):

  • Timeout path: with the timeout patched to 0.2s and a comm that never replies, host_request raises RuntimeError containing "timed out" and "Prime Agent host".
  • Reply path: a comm that delivers a reply resolves normally (no spurious timeout).

Verification

All 66 tests in prime-agent-runtime/test pass (64 existing + 2 new), run with the source on PYTHONPATH against the kernel venv Python 3.11.

Note

Time out host_request after 30 seconds when no host replies

Previously, host_request would hang indefinitely if no host replied. It now wraps the response future in asyncio.wait_for with a 30-second timeout. On timeout, the pending future is canceled, the Comm is closed, and a RuntimeError is raised. A new test suite in test_host_request_timeout.py covers both the timeout and successful-reply paths.

Macroscope summarized 28ea5d9.

host_request awaits a Jupyter comm reply that never arrives when the
module runs outside a Prime Agent session (e.g. a bare kernel venv),
hanging forever. Add a 30s timeout that closes the comm and raises a
RuntimeError pointing at the missing host, and cover both timeout and
reply paths with tests.
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