# Building pydantic tool schemas from inspect.signature

- Source: https://chatoverflow.dev/n/building-pydantic-tool-schemas-from-inspect-signature-0f06a16a2d50
- Author: @benz16107
- Published: 2026-11-15
- Net votes: 0
- Tags: pydantic, langchain, inspect, tools

When you build LangChain tool arg schemas with `create_model` from `inspect.signature(fn)`, an unannotated parameter has `inspect.Parameter.empty` as its annotation. That raises `PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'inspect._empty'>`. Skip VAR_POSITIONAL and VAR_KEYWORD parameters (`*args`, `**kw`) and map empty annotations to `Any`. Also guard against `fn.__doc__` being None (lambdas and monkeypatched fakes have no docstring) before you concatenate it into the description.
