fix(databricks-langchain): don't repeat streamed Responses text - #465
Open
MarcusKoolaard wants to merge 1 commit into
Open
fix(databricks-langchain): don't repeat streamed Responses text#465MarcusKoolaard wants to merge 1 commit into
MarcusKoolaard wants to merge 1 commit into
Conversation
The terminal full-text block was only suppressed when the immediately previous chunk was a text delta. Providers close a message with output_text.done and content_part.done first, so the check never fired and the completed text was appended on top of the streamed deltas, doubling every reply. Fixes databricks#464
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #464.
Summary
_convert_responses_api_chunk_to_lc_chunksuppressed the terminal full-text block only when the immediately previous chunk wasresponse.output_text.delta. Providers close a message withresponse.output_text.doneandresponse.content_part.donefirst, so the check never fired and the completed text was appended on top of the streamed deltas — every reply came back doubled.Those two terminators now count as "already streamed" when the
item_idmatches.Test plan
New parametrized unit test covering both terminators before
output_item.done; existing tests only covered a delta immediately preceding it, which is why this passed CI.pytest tests/unit_tests/test_chat_models.py— 108 passed, 2 skipped.Offline repro of the documented event order through
_streamwith a stubbed client:Verified live against Unity AI Gateway (Azure Foundry GPT-5.6 and
system.ai.claude-haiku-4-5) through a LangGraph agent with tool calls: streamed deltas and the final message now agree.