Skip to content

Conversation

@Aman071106
Copy link

refactor(core): remove redundant annotation preservation in pydantic utility

Description

This PR removes a manual workaround in _create_subset_model_v2 (within libs/core/langchain_core/utils/pydantic.py) that was intended to preserve __annotations__ when using Annotated types with TypedDict. I verified that the current Pydantic V2 version used in langchain-core natively validates and preserves these annotations correctly, rendering the manual workaround and its associated TODO redundant.

Verification

Ran pytest libs/core/tests/unit_tests/utils/test_pydantic.py and confirmed all tests pass.
Additionally, I created a local reproduction script to verify that Annotated[TypedDict, ...] metadata is preserved in the subset model without this manual step.

Checklists

  • PR title follows the format: TYPE(SCOPE): DESCRIPTION
  • Changes are limited to langchain-core package.
  • make format, make lint and make test pass (verified via pytest locally).

@Aman071106 Aman071106 requested a review from eyurtsev as a code owner December 30, 2025 10:29
@github-actions github-actions bot added core `langchain-core` package issues & PRs refactor PRs that include a refactor labels Dec 30, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 30, 2025

CodSpeed Performance Report

Merging #34537 will improve performance by 27.84%

Comparing Aman071106:refactor/pydantic-annotation-cleanup (614ad71) with master (e03d6b8)1

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

⚡ 2 improvements
✅ 11 untouched
⏩ 21 skipped2

Benchmarks breakdown

Mode Benchmark BASE HEAD Efficiency
WallTime test_async_callbacks_in_sync 23.4 ms 18.3 ms +27.84%
WallTime test_import_time[ChatPromptTemplate] 587 ms 530.9 ms +10.57%

Footnotes

  1. No successful run was found on master (721bf15) during the generation of this report, so e03d6b8 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 21 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@cbornet
Copy link
Collaborator

cbornet commented Dec 30, 2025

It seems you rolled-back your changes in the latest commits. The PR doesn't do anything relevant anymore...

@Aman071106
Copy link
Author

It seems you rolled-back your changes in the latest commits. The PR doesn't do anything relevant anymore...

@cbornet Thanks for review. I am back at restoring my implementation .

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

Labels

core `langchain-core` package issues & PRs refactor PRs that include a refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants