Skip to content

An attached client re-acquires its runtime once its spawner exits - #248

Open
abonneth wants to merge 1 commit into
mainfrom
antoine/reacquire-runtime
Open

abonneth wants to merge 1 commit into
mainfrom
antoine/reacquire-runtime

Conversation

@abonneth

@abonneth abonneth commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Made with Cursor


Note

Medium Risk
Changes local runtime lifecycle, session create paths, and runtime identity auth wiring; mistakes could mis-route sessions or accept the wrong process on a port, though behavior is covered by new tests.

Overview
When a local client attaches to a shared runtime whose spawner/watchdog has exited, it can be left talking to a dead port or a squatter. This PR adds RuntimeHold so sync/async Client.local keeps a durable handle (launch recipe + ownership) and can detect a lost runtime and re-attach at the same base URL before new work.

Client / AsyncClient now read local_runtime and ownership through _hold instead of storing a fixed LocalRuntime. Local sessions clients take the hold, call reacquire / reacquire_async before create_session, and bind remote cancel to the runtime of the moment. Runtime identity HTTP clients accept a callable token so bearer auth and HMAC proofs follow a replacement runtime’s new API key without rebuilding the whole client.

Adds an integration test that shuts down the mock runtime, starts a replacement on the same port with a new token, and asserts the next session create uses the fresh credentials.

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

…ned it exits

Co-authored-by: Cursor <cursoragent@cursor.com>
@abonneth
abonneth requested a review from adeprezh as a code owner October 8, 2026 13:48

This branch has not been deployed

No deployments
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