Merged
Conversation
snimu
previously requested changes
Dec 17, 2025
willccbb
reviewed
Dec 17, 2025
willccbb
approved these changes
Dec 17, 2025
d5b5385 to
32e50c3
Compare
| "sandbox_client", | ||
| AsyncSandboxClient, | ||
| **self.client_kwargs, | ||
| ) |
There was a problem hiding this comment.
Bug: Thread-local storage key collision ignores different client configurations
The hardcoded key "sandbox_client" in get_or_create_thread_attr causes all ThreadedAsyncSandboxClient instances to share the same thread-local AsyncSandboxClient. When multiple instances are created with different client_kwargs (e.g., different max_connections values), the first instance to make a call on a thread creates the client with its config, and subsequent instances silently reuse that same client, ignoring their own configurations. The factory kwargs are only used on creation, not on retrieval.
Additional Locations (1)
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.
Description
Implements threading utils that allow creating per-thread storage (e.g. use different clients for each thread in a thread pool executor), and a wrapper class
ThreadedAsyncSandboxClientwhich delegates all calls via sandbox clients to a thread pool, each with their local client. This drastically lowers the error rate when training in PRIME-RL because it unblocks the main orchestrator event loop. Basically makes the difference between being trainable or not.Type of Change
Testing
uv run pytestlocally.Checklist
Additional Notes
Note
Introduce a ThreadPool-backed
ThreadedAsyncSandboxClientwith per-thread event loops/clients and replaceAsyncSandboxClientusage inSandboxEnv, adding configurable limits and teardown.verifiers/envs/sandbox_env.py):AsyncSandboxClientwith newThreadedAsyncSandboxClientusingThreadPoolExecutorand per-thread client/event loop.sandbox_client_max_workers,sandbox_client_max_connections,sandbox_client_max_keepalive_connections.@vf.teardownmethodteardown_sandbox_clientto shut down the executor; keep sync bulk-delete teardown for remaining sandboxes.verifiers/utils/thread_utils.py):get_or_create_thread_attrandget_or_create_thread_loopfor per-thread resource management.Written by Cursor Bugbot for commit 32e50c3. This will update automatically on new commits. Configure here.