Skip to content

bug(@langchain/google) Non-standard property originalTextContentBlock on AIMessageChunk output from .stream() ChatGoogle invoke, is ignored when constructing Gemini API request body. #10562

@vjancik

Description

Checked other resources

  • This is a bug, not a usage question. For questions, please use the LangChain Forum (https://forum.langchain.com/).
  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • 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.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

Refer to .json files attached to this issue #10561

Error Message and Stack Trace (if applicable)

No response

Description

Using .stream() with ChatGoogle and optionally .concat(), the individual chunks have an additional_kwargs property of originalTextContentBlock that is serialized together with the equivalent text content in content. (Doubling the serialized size in the process).
This happens on both outputFormat v0 and v1.

I couldn't find any consumers of this property, or reference to any explanation in upstream Gemini API docs:

https://www.google.com/search?q=gemini+api+%22originalTextContentBlock%22
https://www.google.com/search?q=langchain+%22originalTextContentBlock%22
https://github.com/search?q=repo%3Alangchain-ai%2Flangchainjs%20originalTextContentBlock&type=code

Therefore, there are only two possible reasons in my mind. Either this property is an unused legacy property from previous iterations of the google provider library, or this property is entirely hallucinated by AI and should be removed.

System Info

Package: @langchain/google
Version: 0.1.9
Companion: @langchain/core 1.1.37 (peerDependency enforced)
Runtime: bun 1.3.11
Platform: Ubuntu 25.10 (Linux 6.17.0-14-generic)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions