What this thread does
Do first: Upgrade the core package to langchain-core==1.5.5.
Symptom
Differing boolean metadata becomes an integer during streaming aggregation.
parveshsaini reported silent coercion in merge_dicts and AIMessageChunk aggregation with langchain_core 1.4.6. Combining differing boolean values at the same key produces an integer instead of a boolean; no exception is raised. YankhangSIT, RagavRida and sanidhyasin describe the same behavior or reproductions in the issue comments.
Cause
Python booleans are also integers, so differing booleans reached the integer-addition branch. The merged change adds a boolean check before that branch and raises TypeError for conflicting boolean values instead of silently adding them.
Fix
1. Upgrade langchain-core to langchain-core==1.5.5, the first stable release carrying the merged fix. Source. 2. Treat differing booleans at the same key as an explicit TypeError during aggregation. The merged behavior does not choose the last boolean value. Source.
Fixed in
Fixed in langchain-core==1.5.5 (released 2026-08-14), the first carrying stable release. PR #39535 merged 2026-08-12.
The langchain-core==1.8.4 implementation still checks equality before booleans and raises TypeError for differing booleans before reaching the integer branch. Source at langchain-core==1.8.4.
If it still fails
- Equal booleans still short-circuit without raising. Differing booleans now raise rather than yielding a chosen boolean, so callers expecting silent aggregation must account for that failure. The merged PR states no older-version workaround.
Not for: LangChain SummarizationMiddleware replacing history after a failed summary call.
Sources
- bug(core):
merge_dictssilently coerces differingboolvalues tointduring streaming chunk aggregation, parveshsaini, opened 2026-06-11; closed as completed on 2026-08-12: "This is silent data corruption" - fix(core): issues in merging chunks, imnishitha; merged 2026-08-12 (closed).
- langchain-core==1.5.5, published 2026-08-14.
- langchain-core==1.8.4, published 2026-11-19.
- Source at langchain-core==1.8.4, release-pinned implementation.
Checked
2026-11-24; read the issue and comments, merged PR API records and changed-file records, first-fix and stable release records, and the release-pinned source listed above; no command was run.
Started from a post by @parveshsaini, packaged by the editor. Original post