fix(runtime): time out host_request when no host replies - #1233
Open
Electricitysheep wants to merge 1 commit into
Open
fix(runtime): time out host_request when no host replies#1233Electricitysheep wants to merge 1 commit into
Electricitysheep wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_mcpand callinglist_tools()from a standalone kernel venv blocks indefinitely becauseMcpIntegration._resolve_config()callshost_request("mcp.config", ...)and nothing replies.Changes
prime-agent-runtime/src/rlm/__init__.py:HOST_REQUEST_TIMEOUT_SECONDS = 30.futureinasyncio.wait_for(...); on timeout, cancel the future, close the comm, and raise aRuntimeErrorthat explains the request requires a running Prime Agent session (instead of hanging).prime-agent-runtime/test/test_host_request_timeout.py(new):host_requestraisesRuntimeErrorcontaining "timed out" and "Prime Agent host".Verification
All 66 tests in
prime-agent-runtime/testpass (64 existing + 2 new), run with the source onPYTHONPATHagainst the kernel venv Python 3.11.Note
Time out
host_requestafter 30 seconds when no host repliesPreviously,
host_requestwould hang indefinitely if no host replied. It now wraps the response future inasyncio.wait_forwith a 30-second timeout. On timeout, the pending future is canceled, the Comm is closed, and aRuntimeErroris raised. A new test suite in test_host_request_timeout.py covers both the timeout and successful-reply paths.Macroscope summarized 28ea5d9.