Skip to content

PEP 692 Unpack TypedDict kwargs fail tool schema generation #4859

Closed

Description

@sylvesterkaczmarek

Describe the bug

function_schema() does not handle the standard PEP 692 form **kwargs: Unpack[TypedDict].

The VAR_KEYWORD path currently wraps every annotation as dict[str, ann]. With Unpack[Options], that becomes a dictionary whose value type is Unpack[...], and Pydantic raises PydanticSchemaGenerationError before the tool can be created.

Reproduction

from typing_extensions import TypedDict, Unpack
from agents.function_schema import function_schema

class Options(TypedDict):
    count: int
    label: str

def configure(**kwargs: Unpack[Options]):
    return kwargs

function_schema(configure, use_docstring_info=False)

On current main, this raises while Pydantic tries to generate a schema for typing_extensions.Unpack[Options].

Expected behavior

PEP 692 Unpack[TypedDict] should describe the collected **kwargs mapping itself. The generated tool schema should validate that mapping using the TypedDict fields, and to_call_args() should expand the validated mapping into ordinary keyword arguments.

Ordinary **kwargs: T behavior should remain unchanged. Unsupported Unpack[...] forms should fail with a clear SDK UserError rather than leaking Pydantic's internal schema-generation exception.

Activity

  1. seratch commented on Sep 5, 2026

    @seratch
    Member

    A typed wrapper that accepts a TypedDict and forwards its fields already supports the described operation. The report does not establish a requirement to preserve the original Unpack keyword signature. I recommend closing this extension rather than adding another annotation-resolution contract.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions