GitHub Repo
LangChain Community Reproduces Message-Merging Bug That May Turn the Developer Role into an Invalid String
A LangChain community report on October 31 said that merging consecutive developer messages may concatenate their role names, making the outgoing request invalid. Another participant reproduced the issue, and the author published a fix branch, but maintainers have not confirmed or officially merged it.

On October 31, LangChain received a bug report involving conversation history processing: after two adjacent developer messages were merged with merge_message_runs, the role field became developerdeveloper. The reporter said they reproduced the issue with langchain-core 1.7.3 and a specified commit on the main branch; two other participants posted the same result. At the time of review, the issue remained open. Source: community report and reproduction discussion
The official documentation says the function merges consecutive messages of the same type, joining string content with a newline by default. ToolMessage instances with distinct tool call IDs are not merged. Since this kind of processing can be used before a model call, the original role information must be preserved after merging. Source: LangChain API documentation
According to the report’s analysis, the developer role is stored in SystemMessage as additional_kwargs["__openai_role__"]. The underlying dictionary merge concatenates strings but does not treat this field as a label that should retain a single value. As a result, the content is joined correctly while the role is duplicated; when the message is later converted back to an API message, that value is used directly. The discussion also noted that an ordinary system message and a developer message could be combined into one, changing the output role. Source: root cause discussion
The author’s public fix branch addresses both cases: identical developer labels are retained only once, while system and developer messages remain separate. The author says newly added tests fail on the original version and pass with the fix, but this is the contributor’s validation and does not mean the issue has been fixed in an official release. Source: fix progress
For agent systems that combine standing rules with instructions for each request, this report is a reminder to inspect the role fields actually sent after merging. It does not establish that all LangChain calls are affected. The next things to watch are whether maintainers accept the fix and whether regression tests cover different role orderings.