Conversation
Address the text reconciliation issue identified in leookun#421. Retain baselines across interleaved or late terminal events and adopt an initial unindexed prefix. Cover the provider through HTTP/SSE model-cycle integration tests. Co-authored-by: kevin9327 <kevin9327@users.noreply.github.com>
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.
Responses text completion events describe one output item, but the existing reconciliation baseline accumulates text for the whole response. As a result, later items can lose their entire text or a missing delta suffix. This change retains a baseline per
output_indexfor the lifetime of the response and uses it for bothresponse.output_text.doneand messageresponse.output_item.done.This addresses the issue identified by @kevin9327 in #421 and adds coverage for item indices that return after another item has already emitted text. Clearing one buffer whenever the index changes fixes sequential items but loses the previous item's baseline: interleaved events and late duplicate completion events can then replay text. The first explicit index can also arrive after an unindexed prefix; that prefix is adopted by the newly identified item instead of being emitted twice. Events without an index continue to use the current item.
The implementation retains per-item cumulative text in a map. It leaves function-call handling and the existing prefix-only text reconciliation behavior unchanged.
Validation:
Only the provider change and its integration tests are included. This PR is independent of #487 and the Anthropic refusal fix, with no fork customization or release changes. Related: #421; it does not require that PR to be merged first.
Revalidated on current upstream
main(9a8fde2):cargo test -p cursor-server --all-targetspassed all 264 tests, including all nine Responses integration tests; server all-targets Clippy with-D warnings,cargo fmt --all -- --check, andgit diff --checkpassed. This upstream-only branch contains one production file and one integration-test file.