From 0ea21ef9e055459605d9a47b39c07d59c09737a2 Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 29 Sep 2026 00:56:21 +0000 Subject: [PATCH] test(anthropic): assert upstream request order in multi-turn Claude Code tests Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../providers/anthropic/test_claude_code_compaction_wire.py | 3 ++- .../providers/anthropic/test_claude_code_image_input_wire.py | 3 ++- .../anthropic/test_claude_code_interleaved_thinking_wire.py | 3 ++- .../providers/anthropic/test_claude_code_model_switch_wire.py | 3 ++- .../providers/anthropic/test_claude_code_tool_loop_wire.py | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_compaction_wire.py b/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_compaction_wire.py index 0132cf7a1e6..4be3a2b9977 100644 --- a/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_compaction_wire.py +++ b/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_compaction_wire.py @@ -105,4 +105,5 @@ def test_compaction_edit_and_applied_edit_block_round_trip_through_anthropic(gat "POST", "/v1/messages", {**turn3, "model": model}, params={"beta": "true"}, headers=headers ) assert response2.status_code == 200, response2.text - assert len(wire.drain()) == 2 + bodies: Final = tuple(cc.JSON_OBJECT.validate_json(request.body) for request in wire.drain()) + assert bodies == (first_expected, second_expected), bodies diff --git a/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_image_input_wire.py b/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_image_input_wire.py index 6d2f4d06dec..b77f328403b 100644 --- a/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_image_input_wire.py +++ b/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_image_input_wire.py @@ -64,4 +64,5 @@ def test_tool_result_image_block_and_pasted_image_reach_anthropic_identical(gate "POST", "/v1/messages", {**pasted, "model": model}, params={"beta": "true"}, headers=headers ) assert response2.status_code == 200, response2.text - assert len(wire.drain()) == 2 + bodies: Final = tuple(cc.JSON_OBJECT.validate_json(request.body) for request in wire.drain()) + assert bodies == (first_expected, second_expected), bodies diff --git a/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_interleaved_thinking_wire.py b/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_interleaved_thinking_wire.py index f5da9b070f5..ff8ccf0df4f 100644 --- a/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_interleaved_thinking_wire.py +++ b/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_interleaved_thinking_wire.py @@ -163,4 +163,5 @@ def test_interleaved_thinking_text_and_tool_use_history_reaches_anthropic_identi ] assert started == [(0, "thinking"), (1, "text"), (2, "tool_use")], started assert events[-1][0] == "message_stop" - assert len(wire.drain()) == 2 + bodies: Final = tuple(cc.JSON_OBJECT.validate_json(request.body) for request in wire.drain()) + assert bodies == (turn2_expected, turn3_expected), bodies diff --git a/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_model_switch_wire.py b/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_model_switch_wire.py index c04b974da01..05b936c93f3 100644 --- a/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_model_switch_wire.py +++ b/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_model_switch_wire.py @@ -71,7 +71,8 @@ def test_claude_code_mid_loop_model_switch_replays_history_byte_identical(gatewa "POST", "/v1/messages", {**turn2, "model": opus}, params={"beta": "true"}, headers=headers ) assert response2.status_code == 200, response2.text - assert len(wire.drain()) == 2 + bodies: Final = tuple(cc.JSON_OBJECT.validate_json(request.body) for request in wire.drain()) + assert bodies == (first_expected, second_expected), bodies rows: Final = eventually( lambda: read_rows( 'SELECT model FROM "LiteLLM_SpendLogs" WHERE request_id=%s', diff --git a/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_tool_loop_wire.py b/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_tool_loop_wire.py index 0fd9828186d..39bda48c2c4 100644 --- a/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_tool_loop_wire.py +++ b/tests/integration/messages_endpoint/providers/anthropic/test_claude_code_tool_loop_wire.py @@ -101,7 +101,8 @@ def test_claude_code_tool_loop_round_trips_thinking_tool_use_and_tool_result(gat events2: Final = cc.sse_events(response2.text) assert events2[2][1]["delta"] == {"type": "text_delta", "text": "PROBE"} assert events2[4][1]["delta"]["stop_reason"] == "end_turn" - assert len(wire.drain()) == 2 + bodies: Final = tuple(cc.JSON_OBJECT.validate_json(request.body) for request in wire.drain()) + assert bodies == (first_expected, second_expected), bodies rows: Final = eventually( lambda: read_rows( 'SELECT prompt_tokens FROM "LiteLLM_SpendLogs" WHERE request_id=%s',