Skip to content

@tool builds an empty input schema, with no error, for an input_schema it does not recognize (typing_extensions.TypedDict on Python 3.11 and later) #1337

Description

@codyanthony736

_build_input_schema returns {"type": "object", "properties": {}} for any input_schema that is neither a dict nor a class is_typeddict accepts (claude_agent_sdk/__init__.py lines 428 to 430 at 0.2.160). The tool then registers with no parameters and no warning.

On Python 3.11 and later the SDK imports is_typeddict from the standard library (lines 19 to 21), which does not recognize a class built on typing_extensions.TypedDict. Observed on Python 3.11.16 with claude-agent-sdk 0.2.160 and typing_extensions 4.16.0: a typing_extensions.TypedDict class with one NotRequired key gives {"properties": {}, "type": "object"}, while the same class built on typing.TypedDict gives the full schema with required: ["latitude"]. On 3.10 the typing_extensions branch (lines 22 to 26) recognizes both.

Expected: either recognize typing_extensions.TypedDict on every version (typing_extensions.is_typeddict accepts both metaclasses), or raise a TypeError for an unrecognized input_schema instead of registering an empty one.

Minimal repro:

import json, sys, typing
import typing_extensions as te
import claude_agent_sdk as sdk
from claude_agent_sdk import tool

class TeArgs(te.TypedDict):
    latitude: te.Annotated[float, "Latitude coordinate"]
    hours: te.NotRequired[te.Annotated[int, "How many hours of forecast to return"]]

class StdArgs(typing.TypedDict):
    latitude: typing.Annotated[float, "Latitude coordinate"]
    hours: te.NotRequired[typing.Annotated[int, "How many hours of forecast to return"]]

for cls in (TeArgs, StdArgs):
    @tool("probe", "probe", cls)
    async def probe(args):
        return {"content": [{"type": "text", "text": str(args)}]}
    print(sys.version.split()[0], cls.__name__, sdk.is_typeddict(cls),
          json.dumps(sdk._build_input_schema(probe), sort_keys=True))

Output on 3.11.16 / 0.2.160 / typing_extensions 4.16.0:

3.11.16 TeArgs False {"properties": {}, "type": "object"}
3.11.16 StdArgs True {"properties": {"hours": {"description": "How many hours of forecast to return", "type": "integer"}, "latitude": {"description": "Latitude coordinate", "type": "number"}}, "required": ["latitude"], "type": "object"}

Activity

  1. redswimmer commented on Oct 1, 2026

    @redswimmer

    Fixed in PR #1341

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions