fix(core): treat status as a last-wins field when merging chunks

"status" fields on streamed content blocks (e.g. a Responses API
function_call moving from "in_progress" to "completed") are enum-like
state, not accumulated text. merge_dicts previously concatenated two
string "status" values like any other string, corrupting them into
values like "in_progresscompleted" once a provider integration started
carrying status across chunks.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
This commit is contained in:
Nishitha Mandopen-swe[bot] committed 2026-08-10 17:11:59 +00:00
1 parent 00592c9b22
commit dbc1fbf931
2 files changed
+10

No files matched your search

+5
View File
@@ -61,6 +61,11 @@ def merge_dicts(left: dict[str, Any], *others: dict[str, Any]) -> dict[str, Any]
and merged[right_k] == right_v
):
continue
if right_k == "status":
# Enum-like state (e.g. "in_progress" -> "completed") that a
# later chunk overwrites, not accumulated text.
merged[right_k] = right_v
continue
merged[right_k] += right_v
elif isinstance(merged[right_k], dict):
merged[right_k] = merge_dicts(merged[right_k], right_v)
@@ -129,6 +129,11 @@ def test_check_package_version(
# Other integer fields should still be summed (e.g., token counts)
({"tokens": 10}, {"tokens": 5}, {"tokens": 15}),
({"count": 1}, {"count": 2}, {"count": 3}),
# 'status' is enum-like state that a later chunk overwrites, not
# accumulated text (e.g. streamed Responses API items going from
# "in_progress" to "completed").
({"status": "in_progress"}, {"status": "completed"}, {"status": "completed"}),
({"status": "completed"}, {"status": "completed"}, {"status": "completed"}),
],
)
def test_merge_dicts(