You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: allow synchronous client tools after restarting - #900
After a ClientTools.start() / stop() / start() cycle, synchronous tools fail with RuntimeError: cannot schedule new futures after shutdown. The event loop restarts, but stop() permanently shuts down the executor that handle() continues using.
Replace the retired executor with a fresh, lazy ThreadPoolExecutor after shutdown. Registered tools remain available, and stopping a custom loop still leaves that caller-owned loop open. Only .fernignore hand-maintained files are changed.
The new regression fails before the fix for both the default background loop and a caller-supplied loop. All 53 client-tool and conversation tests pass afterward. Ruff syntax checks pass; full Ruff reports the same two import-order and two unused-import findings on the branch and unchanged main. No live provider requests were made.
Low Risk
Small lifecycle fix in ClientTools resource cleanup with a focused regression test; no auth, networking, or API contract changes.
Overview
Fixes sync client tools breaking after a start() / stop() / start() cycle. ClientTools.stop() still shuts down the ThreadPoolExecutor used for synchronous handlers, but it now replaces it with a new executor so later handle() calls can schedule work again instead of raising RuntimeError: cannot schedule new futures after shutdown.
Adds test_sync_tool_can_run_after_restart, parametrized for both the default background loop and a caller-supplied loop, to assert registered sync tools keep working across repeated start/stop cycles.
Reviewed by Cursor Bugbot for commit 806568e. Bugbot is set up for automated code reviews on this repo. Configure here.
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
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.
After a
ClientTools.start()/stop()/start()cycle, synchronous tools fail withRuntimeError: cannot schedule new futures after shutdown. The event loop restarts, butstop()permanently shuts down the executor thathandle()continues using.Replace the retired executor with a fresh, lazy
ThreadPoolExecutorafter shutdown. Registered tools remain available, and stopping a custom loop still leaves that caller-owned loop open. Only.fernignorehand-maintained files are changed.The new regression fails before the fix for both the default background loop and a caller-supplied loop. All 53 client-tool and conversation tests pass afterward. Ruff syntax checks pass; full Ruff reports the same two import-order and two unused-import findings on the branch and unchanged main. No live provider requests were made.