Avatar for the langchain-ai user
langchain-ai
langchain
BlogDocsChangelog

fix(core): prevent inflated token counts when merging streaming usage_metadata

#35615
Comparing
ShresthSamyak:fix-streaming-token-count
(
ce9e7a3
) with
master
(
29134dc
)
CodSpeed Performance Gauge
+2%
Untouched
13
Skipped
23

Benchmarks

36 total
test_import_time[Runnable]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+3%
538 ms*522.2 ms
test_import_time[CallbackManager]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+3%
341.3 ms*332.2 ms
test_import_time[InMemoryRateLimiter]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+3%
186 ms*181.1 ms
test_import_time[InMemoryVectorStore]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+3%
650.8 ms*634.6 ms
test_import_time[ChatPromptTemplate]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+2%
682.8 ms*666.9 ms
test_import_time[RunnableLambda]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+2%
537.2 ms*524.8 ms
test_import_time[Document]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+2%
198 ms*194.1 ms
test_import_time[tool]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+2%
587.4 ms*578.6 ms
test_import_time[BaseChatModel]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+1%
573.8 ms*565.7 ms
test_import_time[PydanticOutputParser]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+1%
583 ms*575.2 ms
test_import_time[HumanMessage]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+1%
279.1 ms*276.5 ms
test_async_callbacks_in_sync
libs/core/tests/benchmarks/test_async_callbacks.py
CodSpeed Performance Gauge
+1%
25.6 ms*25.4 ms
test_import_time[LangChainTracer]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
0%
485.8 ms*483.5 ms
test_create_chat_prompt_init_time
libs/partners/prompty/tests/unit_tests/test_standard.py
Skipped
311.9 µs*
test_qdrant_vectorstore_init_time
libs/partners/qdrant/tests/unit_tests/test_standard.py
Skipped
225 ms*
test_exa_retriever_init_time
libs/partners/exa/tests/unit_tests/test_standard.py
Skipped
316.4 µs*
test_init_time
libs/partners/ollama/tests/unit_tests/test_chat_models.py::TestChatOllama
Skipped
1.6 s*
test_nomic_embeddings_init_time
libs/partners/nomic/tests/unit_tests/test_standard.py
Skipped
1.5 ms*
test_init_time
libs/partners/mistralai/tests/unit_tests/test_standard.py::TestMistralStandard
Skipped
9.2 ms*
test_init_time
libs/partners/xai/tests/unit_tests/test_chat_models_standard.py::TestXAIStandard
Skipped
3.3 s*
test_init_time
libs/partners/perplexity/tests/unit_tests/test_chat_models_standard.py::TestPerplexityStandard
Skipped
1.7 s*
test_init_time
libs/partners/anthropic/tests/unit_tests/test_standard.py::TestAnthropicBedrockStandard
Skipped
1.1 ms*
test_init_time
libs/partners/deepseek/tests/unit_tests/test_chat_models.py::TestChatDeepSeekUnit
Skipped
1.6 s*
test_chroma_init_time
libs/partners/chroma/tests/unit_tests/test_standard.py
Skipped
60.7 ms*
test_init_time
libs/partners/fireworks/tests/unit_tests/test_standard.py::TestFireworksStandard
Skipped
6.6 s*

Commits

Click on a commit to change the comparison range
Base
master
29134dc
+3.91%
fix(core): prevent inflated token counts when merging streaming usage_metadata
26a849c
4 months ago
by ShresthSamyak
-0.62%
fix(core): handle cumulative usage_metadata in streaming merges without breaking normal merge behavior
98321ca
4 months ago
by ShresthSamyak
-1.42%
fix(core): correctly merge cumulative and delta usage_metadata
12ec745
4 months ago
by ShresthSamyak
+21.02%
style(core): fix lint formatting
17fb544
4 months ago
by ShresthSamyak
-21.05%
Merge branch 'master' into fix-streaming-token-count
ce9e7a3
4 months ago
by ShresthSamyak
© 2026 CodSpeed Technology
Home Terms Privacy Docs