-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Description
Checked other resources
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar question and didn't find it.
- I am sure that this is a bug in LangChain rather than my code.
- The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
- I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.
Example Code
from langchain_core.outputs import GenerationChunk
chunk1 = GenerationChunk(text="", generation_info={"len": 0})
chunk2 = GenerationChunk(text="Non-empty text", generation_info={"len": 14})
result = chunk1 + chunk2 # Raises TypeError
Error Message and Stack Trace (if applicable)
TypeError: Additional kwargs key len already exists in left dict and value has unsupported type <class 'int'>.
Description
When I tried adding two GenerationChunk instances that have the same key in their generation_info, it raised a TypeError. I expected GenerationChunk addition to handle this properly, since GenerationChunk often contains metadata like len, index, etc., which can have duplicate keys.
System Info
System Information
OS: Linux
OS Version: #148-Ubuntu SMP Fri Mar 14 19:05:48 UTC 2025
Python Version: 3.10.16 (main, Dec 11 2024, 16:24:50) [GCC 11.2.0]
Package Information
langchain_core: 0.3.28
langchain: 0.3.13
langchain_community: 0.3.13
langsmith: 0.1.137
langchain_anthropic: 0.3.1
langchain_aws: 0.2.2
langchain_chroma: 0.2.0
langchain_experimental: 0.3.2
langchain_fireworks: 0.2.6
langchain_google_vertexai: 2.0.5
langchain_groq: 0.2.2
langchain_mistralai: 0.2.4
langchain_openai: 0.2.14
langchain_text_splitters: 0.3.4
langchain_together: 0.2.0
langchain_unstructured: 0.1.5
langgraph_sdk: 0.1.34
Optional packages not installed
langserve
Other Dependencies
aiohttp: 3.10.10
anthropic: 0.40.0
anthropic[vertexai]: Installed. No version info available.
async-timeout: 4.0.3
boto3: 1.35.42
chromadb: 0.5.15
dataclasses-json: 0.6.7
defusedxml: 0.7.1
fastapi: 0.115.3
fireworks-ai: 0.15.7
google-cloud-aiplatform: 1.70.0
google-cloud-storage: 2.18.2
groq: 0.11.0
httpx: 0.28.1
httpx-sse: 0.4.0
jsonpatch: 1.33
numpy: 1.26.4
openai: 1.57.4
orjson: 3.10.16
packaging: 24.1
pydantic: 2.11.1
pydantic-settings: 2.6.0
PyYAML: 6.0.2
requests: 2.32.3
requests-toolbelt: 1.0.0
SQLAlchemy: 2.0.40
tenacity: 9.0.0
tiktoken: 0.8.0
tokenizers: 0.21.0
typing-extensions: 4.13.0
unstructured-client: 0.25.9
unstructured[all-docs]: Installed. No version info available.