Skip to content

fix: allow synchronous client tools after restarting - #900

Merged
kraenhansen merged 1 commit into
elevenlabs:mainfrom
Apeksha9389:fix/restart-client-tools
Nov 19, 2026
Merged

kraenhansen merged 1 commit into
elevenlabs:mainfrom
Apeksha9389:fix/restart-client-tools

Conversation

@Apeksha9389

Copy link
Copy Markdown
Contributor

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.

@cursor

cursor Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

PR Summary

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.

@kraenhansen kraenhansen self-assigned this Nov 19, 2026
@kraenhansen
kraenhansen merged commit 590ed50 into elevenlabs:main Nov 19, 2026
1 check passed
@kraenhansen

Copy link
Copy Markdown
Member

Thanks a lot for the fix and sorry for the wait here! 🙏

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.

2 participants