## Summary Fixes #34247 When using `Annotated[type, Field(description="...")]` syntax with the `@tool` decorator, field descriptions were being lost during schema generation. The `_get_annotation_description()` function only checked for string annotations but not for Pydantic `FieldInfo` objects. ## Changes - Extended `_get_annotation_description()` to also extract descriptions from `FieldInfo` objects within `Annotated` types - Added import for `pydantic.fields.FieldInfo` - Added unit test to verify `Field(description=...)` is preserved ## Why this approach The fix is minimal and targeted - it extends the existing description extraction logic rather than restructuring the schema generation. This maintains backward compatibility while supporting both annotation styles: ```python # Both now work correctly: topic: Annotated[str, "The research topic"] # existing topic: Annotated[str, Field(description="...")] # now fixed ``` ## Known limitation This fix only handles `pydantic.fields.FieldInfo` (Pydantic v2). The v1 compatibility layer (`pydantic.v1.fields.FieldInfo`) is a different class and will not have descriptions extracted. This is intentional: - Pydantic v1 is deprecated; users should migrate to v2 - The v1 compat layer exists for legacy model migration, not new tool definitions - Duck-typing on `description` attribute could match unintended objects If v1 `Field` support is needed, it can be addressed in a follow-up PR with explicit handling. ## Testing - Added `test_tool_field_description_preserved()` covering required and optional params - Verified existing `test_tool_annotated_descriptions` still passes - Lint and type checks pass --- > [!NOTE] > This PR was developed with AI agent assistance (Factory/Droid). --------- Co-authored-by: Mason Daugherty <github@mdrxy.com>
Packages
Important
This repository is structured as a monorepo, with various packages located in this libs/ directory. Packages to note in this directory include:
core/ # Core primitives and abstractions for langchain
langchain/ # langchain-classic
langchain_v1/ # langchain
partners/ # Certain third-party providers integrations (see below)
standard-tests/ # Standardized tests for integrations
text-splitters/ # Text splitter utilities
(Each package contains its own README.md file with specific details about that package.)
Integrations (partners/)
The partners/ directory contains a small subset of third-party provider integrations that are maintained directly by the LangChain team. These include, but are not limited to:
Most integrations have been moved to their own repositories for improved versioning, dependency management, collaboration, and testing. This includes packages from popular providers such as Google and AWS. Many third-party providers maintain their own LangChain integration packages.
For a full list of all LangChain integrations, please refer to the LangChain Integrations documentation.