From a434f3aa08a3cd384db74b788260dae7084edf01 Mon Sep 17 00:00:00 2001 From: ccurme Date: Thu, 5 Feb 2026 09:37:25 -0500 Subject: [PATCH] fix(langchain): bump min core version and improve approximate token counting (#35026) --- .../langchain/agents/middleware/summarization.py | 6 ++++-- libs/langchain_v1/pyproject.toml | 2 +- libs/langchain_v1/uv.lock | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libs/langchain_v1/langchain/agents/middleware/summarization.py b/libs/langchain_v1/langchain/agents/middleware/summarization.py index cd5a38b0b71..a59b23ffc03 100644 --- a/libs/langchain_v1/langchain/agents/middleware/summarization.py +++ b/libs/langchain_v1/langchain/agents/middleware/summarization.py @@ -144,8 +144,10 @@ def _get_approximate_token_counter(model: BaseChatModel) -> TokenCounter: if model._llm_type == "anthropic-chat": # noqa: SLF001 # 3.3 was estimated in an offline experiment, comparing with Claude's token-counting # API: https://platform.claude.com/docs/en/build-with-claude/token-counting - return partial(count_tokens_approximately, chars_per_token=3.3) - return count_tokens_approximately + return partial( + count_tokens_approximately, use_usage_metadata_scaling=True, chars_per_token=3.3 + ) + return partial(count_tokens_approximately, use_usage_metadata_scaling=True) class SummarizationMiddleware(AgentMiddleware[AgentState[ResponseT], ContextT, ResponseT]): diff --git a/libs/langchain_v1/pyproject.toml b/libs/langchain_v1/pyproject.toml index 6828a11d883..8b7bd1c9452 100644 --- a/libs/langchain_v1/pyproject.toml +++ b/libs/langchain_v1/pyproject.toml @@ -24,7 +24,7 @@ classifiers = [ version = "1.2.9" requires-python = ">=3.10.0,<4.0.0" dependencies = [ - "langchain-core>=1.2.8,<2.0.0", + "langchain-core>=1.2.9,<2.0.0", "langgraph>=1.0.7,<1.1.0", "pydantic>=2.7.4,<3.0.0", ] diff --git a/libs/langchain_v1/uv.lock b/libs/langchain_v1/uv.lock index 0b7efb148dc..fc92e0beab6 100644 --- a/libs/langchain_v1/uv.lock +++ b/libs/langchain_v1/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 3 +revision = 2 requires-python = ">=3.10.0, <4.0.0" resolution-markers = [ "python_full_version >= '3.14' and platform_python_implementation == 'PyPy'", @@ -2125,7 +2125,7 @@ wheels = [ [[package]] name = "langchain-core" -version = "1.2.8" +version = "1.2.9" source = { editable = "../core" } dependencies = [ { name = "jsonpatch" },