Back Home

GitHub Repo

LangChain Community Reports Streaming Parsing Issue That May Treat Truncated Parameters as Valid Tool Calls

A LangChain community report on October 17 says incomplete tool parameters may be completed into valid JSON after a stream ends, then enter the tool execution flow. Another contributor reproduced the issue, but a proposed fix was automatically closed during contribution checks and has not been merged.

Dirck van Baburen · Public domain · Image source
zh-Hant

On October 17, the LangChain community reported a tool-call parsing issue: if a model stream ends before its parameters have been fully sent, the final message may still contain apparently valid tool_calls, while invalid_tool_calls remains empty. The reported environment used langchain-core 1.6.12, and another contributor said they had reproduced the issue. The finding concerns how agents determine whether tool input has been fully received. Issue report

A minimal example simulates a document-editing tool: its parameters are truncated at the string hea, but after being assembled by generate_from_stream, they form a parameter object containing that fragment. The reporter said a real-world case applied half of a document edit as if it were complete; this remains a community-reported claim, with no full assessment of the impact or maintainer confirmation. Reproduction code and discussion

The key issue is that the stream preview and final input validation both use permissive parsing. The official documentation says parse_partial_json can handle JSON that is missing closing brackets, which helps interfaces display parameters as they are generated. According to the report’s analysis, the final assembly path uses the same behavior, so when data transmission ends, the syntax may be completed even though the content is still incomplete. Official parser documentation

The proposed fix, submitted that day, called for strict re-parsing during the final message_chunk_to_message conversion, placing failed items and their original strings in invalid_tool_calls while retaining permissive parsing during streaming. The author said they had added regression tests covering truncated parameters, complete parameters, and streaming behavior. However, the proposal was closed by a bot because the author had not yet been assigned the issue. That is a process outcome; it should not be read as acceptance of the fix or rejection of its technical approach. Proposed fix

For engineering teams, this highlights a risk at the tool-execution boundary: the fact that parameters can be converted into an object does not necessarily mean the model fully generated its intended operation. Based on the mechanism described above, tools with side effects, such as document editing, warrant checks for the integrity of the original parameters and relevant business conditions. Next, watch whether maintainers adopt final-stage re-parsing and which streaming entry points are covered by a fix; no official fix release has been confirmed yet.

Sources

  1. LangChain issue #41285:截斷工具參數在串流結束後被寬鬆解析
  2. LangChain PR #41286:最終訊息重新嚴格解析工具參數
  3. LangChain 官方參考文件:parse_partial_json