Repository navigation
Python: Concatenate code-interpreter stream deltas with prefix overlap (#8955) - #9142
Merged
Eduard van Valkenburg (eavanvalkenburg) merged 3 commits intoOct 12, 2026
Conversation
…verlap (microsoft#8955) Stop treating string-prefix relationships as a full resend. Only replace accumulated text when the incoming payload is a provider *.done / complete value; ordinary deltas always concatenate (also covers microsoft#8903). Co-authored-by: Cursor <cursoragent@cursor.com>
lsmlhi_25 (FOWEPJF255)
requested review from
SergeyMenshykh,
Tao Chen (TaoChenOSU),
Eduard van Valkenburg (eavanvalkenburg),
Giles Odigwe (giles17),
Jose Alvarez (jpalvarezl),
Evan Mattson (moonbox3),
Roger Barreto (rogerbarreto),
sophia-ramsey and
westey (westey-m)
as code owners
October 7, 2026 10:16
lsmlhi_25 (FOWEPJF255)
temporarily deployed
to
github-app-auth
October 7, 2026 10:16 — with
GitHub Actions
Inactive
lsmlhi_25 (FOWEPJF255)
temporarily deployed
to
github-app-auth
October 7, 2026 10:16 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Empty lists can raise IndexError, and an existing session-history test now fails.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Fixes corruption when aggregating prefix-overlapping code-interpreter stream deltas.
Changes:
- Concatenates ordinary deltas unconditionally.
- Replaces accumulated text for explicitly completed payloads.
- Adds regression tests for prefix overlap and done events.
| File | Description |
|---|---|
python/packages/core/agent_framework/_types.py |
Updates code-interpreter stream merging. |
python/packages/core/tests/core/test_types.py |
Adds aggregation regression tests. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Handle empty accumulated outputs without IndexError, and mark the session-history full-code snapshot as stream_complete so it replaces deltas instead of concatenating. Co-authored-by: Cursor <cursoragent@cursor.com>
lsmlhi_25 (FOWEPJF255)
temporarily deployed
to
github-app-auth
October 7, 2026 10:25 — with
GitHub Actions
Inactive
Contributor
Author
|
Thanks Copilot -- addressed both findings in
|
…icrosoft#8955) Drop OpenAI *.done raw_representation checks from core. Providers mark authoritative snapshots with additional_properties stream_complete; OpenAI done events now set that flag. Co-authored-by: Cursor <cursoragent@cursor.com>
lsmlhi_25 (FOWEPJF255)
temporarily deployed
to
github-app-auth
October 8, 2026 16:32 — with
GitHub Actions
Inactive
Contributor
Author
|
Thanks Eduard van Valkenburg (@eavanvalkenburg) -- agreed. In
|
Eduard van Valkenburg (eavanvalkenburg)
approved these changes
Oct 9, 2026
Closed
7 tasks
This branch was previously deployed
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.

Summary
code_interpreterinput/output deltas were silently dropped when one chunk's text was a string prefix of another (e.g."("then"()", or indent whitespace then the indented line)._merge_content_item_liststreated any prefix relationship as an OpenAI-style full resend and discarded one side.*.doneraw_representation.type, orstream_complete/completeonadditional_properties).Test plan
python -m pytest tests/core/test_types.py -k "code_interpreter_tool_call_stream or code_interpreter_tool_call_content or code_interpreter_tool_result_content" -qCloses #8955