Repository navigation
fix: recognize typing_extensions.TypedDict input schemas on Python 3.11+ - #1341
Open
redswimmer wants to merge 2 commits into
Open
redswimmer wants to merge 2 commits into
redswimmer wants to merge 2 commits into
Conversation
On 3.11+ the SDK used the stdlib is_typeddict, which does not recognize classes built on typing_extensions.TypedDict (typing_extensions ships its own TypedDict implementation from 4.6 onward). @tool then published such tools with an empty input schema and no warning. Use typing_extensions.is_typeddict on every Python version (it accepts both spellings) and declare typing_extensions as an unconditional dependency. The floor moves to 4.1.0, the first release with is_typeddict. Adds a regression test covering both TypedDict spellings, NotRequired, Annotated descriptions and a nested TypedDict through create_sdk_mcp_server. Fixes anthropics#1337 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EDXJ5Yg4PTHTtKeDw3b7CY
Parametrize directly on the two TypedDict bases with readable ids, describe the behavior in a docstring like the surrounding tests, and drop the importlib indirection and type-ignore comments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EDXJ5Yg4PTHTtKeDw3b7CY
sigley
approved these changes
Oct 7, 2026
sigley
left a comment
There was a problem hiding this comment.
Validated exact head d433bf6 independently. On current main, a typing_extensions.TypedDict input schema reproduces as an empty object schema; this head recognizes the same class and emits the expected typed properties/required set. The branch merges cleanly with current main, the targeted TypedDict cases pass 6/6, the full MCP integration slice passes 146/146, and compile/diff checks are clean. One non-blocking integration note: if #1325 lands first, the pyproject conflict should preserve its AnyIO 4.5 floor while keeping this PR's unconditional typing_extensions>=4.1.0 requirement.
This branch has not been deployed
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.
Fixes #1337
Problem
On Python 3.11+, the SDK uses stdlib
typing.is_typeddict, which returnsFalsefor classes built ontyping_extensions.TypedDict(a separate implementation sincetyping_extensions4.6)._build_input_schemathen falls through to{"type": "object", "properties": {}}, so the tool reaches the model with no parameters and no warning. 3.10 is unaffected because it already usestyping_extensions.is_typeddict.Fix
is_typeddictfromtyping_extensionson every Python version; it accepts both TypedDict spellings.typing_extensionsan unconditional dependency, since the SDK now imports it on every version. Raise the floor from4.0.0to4.1.0:is_typeddictdoesn't exist in 4.0.0, so the old floor also broke the import on 3.10.mcp/pydanticalready require a newer version, so resolved installs don't change.Verification
Ran the reproduction script from the issue with
typing_extensions4.16.0:required: ["latitude"]test_typeddict_schema_for_either_typeddict_spellingregisters a tool throughcreate_sdk_mcp_server, reads the schema back vialist_tools, and covers both spellings,Annotated,NotRequiredand a nested TypedDict. It fails onmain(assert {} == {...}) and passes with the fix.pyteston 3.10–3.13: all pass ·mypy: clean ·ruff: clean