Skip to content

The agent engineering platform.

fix(langchain): bump min core version and improve approximate token counting (#35026)

ccurmea434f3aa08a3
diff --git a/libs/langchain_v1/langchain/agents/middleware/summarization.py b/libs/langchain_v1/langchain/agents/middleware/summarization.py
index cd5a38b0b7..a59b23ffc0 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 6828a11d88..8b7bd1c945 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 0b7efb148d..fc92e0beab 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" },