Repository navigation
Client keeps the caller's headers; restate.ext.pydantic imports without the MCP extra - #307
Merged
Merged
Conversation
…p extra _toolset.py imported pydantic_ai.mcp at module level, so importing restate.ext.pydantic failed unless pydantic-ai-slim[mcp] was installed, although _agent.py already treats MCP support as optional. Move RestateMCPToolset into its own module that is only imported lazily.
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
I reviewed both cherry-picked fixes, and checked each one against the base locally.
Clientno longer mutates the caller'sheaders:do_callnow copies the dict before addingContent-Type, and it finds a caller's override in any letter case.tests/client_headers.pycovers no override plus three casings, checks that the caller's dict is unchanged, and passes locally (4 tests).restate.ext.pydanticimports without the MCP extra:RestateMCPToolsetand its result types move unchanged to_mcp_toolset.py, which is imported only inside the existingtry/except ImportErrorinset_context. In a.venvwithoutpydantic-ai-slim[mcp], the base_toolset.pyfails on its top-levelpydantic_ai.mcpimport, whileimport restate.ext.pydanticsucceeds on this branch. Nothing else references the moved symbols, andruffcheck and format are clean.
claude-opus-5-5 | 𝕏
This was referenced Nov 9, 2026
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.

Two community fixes, cherry-picked with their authorship kept.
Clientcopies the caller'sheadersbefore it adds aContent-Type, so one dict can be reused across handlers with different content types, and aContent-Typeoverride is found in any letter case. Before, the first call wrote its JSONContent-Typeinto the caller's dict and a later call to a binary handler failed with HTTP 400._mcp_toolset.py, imported only when anMCPToolsetis used, sorestate.ext.pydanticimports withoutpydantic-ai-slim[mcp]. The test fix(pydantic): import restate.ext.pydantic without the pydantic-ai mcp extra #257 first added is left out.Tested locally:
tests/client_headers.pypasses.pydantic_aiextra,restate.ext.pydanticimports on this branch and fails on main; withpydantic-ai-slim[mcp]added, anMCPToolsetis still wrapped asRestateMCPToolset.Closes #298, #257, #246.