fix: restore context vars in resolve_tool endpoint#781
Merged
kichanyurd merged 1 commit intoemcie-co:developfrom Apr 21, 2026
Merged
fix: restore context vars in resolve_tool endpoint#781kichanyurd merged 1 commit intoemcie-co:developfrom
kichanyurd merged 1 commit intoemcie-co:developfrom
Conversation
Uvicorn 0.39.0+ fixed contextvar propagation, causing p.Server.current to become unavailable in the resolve_tool endpoint. This breaks choice providers that depend on p.Server.current. This fix follows the same pattern used in call_tool, restoring context vars before processing the request. Signed-off-by: Flow Jiang <flowjzh@gmail.com>
Contributor
|
Good catch, I bet this manifested in the usage of choice provider. Merged! |
|
I've reverted the changes in Uvicorn. It will be available in the next release (in a few minutes). |
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
Fix context var propagation in
resolve_toolendpoint for uvicorn 0.39.0+.Problem
Uvicorn PR #2742 fixed contextvar loading
in version 0.39.0. Previously,
p.Server.currentwas accessible in theresolve_toolendpoint, but after uvicorn 0.39.0 it became unavailable.
This breaks choice providers that depend on
p.Server.current, causing:Solution
Restore context vars in the
resolve_toolendpoint, following the same patternused in the
call_toolendpoint:This ensures
p.Server.currentis accessible regardless of uvicorn version.Testing
References
call_toolendpoint (line ~716)