Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test: expect the list-position index on streamed thinking blocks in the integration suite (#46618)

Kerry Lua9d6123a4396
diff --git a/tests/integration/_support/anthropic_thinking.py b/tests/integration/_support/anthropic_thinking.py
index e055451320e..56d8d74f55e 100644
--- a/tests/integration/_support/anthropic_thinking.py
+++ b/tests/integration/_support/anthropic_thinking.py
@@ -205,8 +205,8 @@ def thinking_block(thinking: str, signature: JsonValue) -> Event:
return {"type": "thinking", "thinking": thinking, "signature": signature}
-def signature_only(signature: JsonValue = SIGNATURE) -> Event:
- return thinking_block("", signature)
+def signature_only(signature: JsonValue = SIGNATURE, index: int = 0) -> Event:
+ return {**thinking_block("", signature), "index": index}
@dataclass(frozen=True, slots=True)
diff --git a/tests/integration/providers/test_anthropic_thinking_signature_stream_wire.py b/tests/integration/providers/test_anthropic_thinking_signature_stream_wire.py
index fc0234410bb..1f42ffb6db6 100644
--- a/tests/integration/providers/test_anthropic_thinking_signature_stream_wire.py
+++ b/tests/integration/providers/test_anthropic_thinking_signature_stream_wire.py
@@ -394,7 +394,7 @@ def test_two_signed_blocks_each_keep_their_own_text_through_a_replay(gateway: Ga
first: Final = _stream_chat(gateway, _chat_body(model, marker))
assert first.status_code == 200, first.text
deltas: Final = deltas_of(chunks_of(first.text))
- assert signed_blocks(deltas) == (signature_only(SIGNATURE), signature_only(_SECOND_SIGNATURE)), deltas
+ assert signed_blocks(deltas) == (signature_only(SIGNATURE), signature_only(_SECOND_SIGNATURE, index=1)), deltas
assert accumulate(deltas) == (
thinking_block("one two", SIGNATURE),
thinking_block("three four", _SECOND_SIGNATURE),
@@ -465,7 +465,7 @@ def test_signature_only_block_without_thinking_deltas_is_relayed_as_is(gateway:
assert response.status_code == 200, response.text
deltas: Final = deltas_of(chunks_of(response.text))
assert signed_blocks(deltas) == (signature_only(SIGNATURE),), deltas
- assert accumulate(deltas) == (signature_only(SIGNATURE),), deltas
+ assert accumulate(deltas) == (thinking_block("", SIGNATURE),), deltas
assert reasoning_text(deltas) == "", deltas
assert content_text(deltas) == answer(marker), deltas
assert len(wire.drain()) == 1
diff --git a/tests/integration/providers/test_bedrock_converse_redacted_thinking_wire.py b/tests/integration/providers/test_bedrock_converse_redacted_thinking_wire.py
index ca0c9319c42..79ec0545c44 100644
--- a/tests/integration/providers/test_bedrock_converse_redacted_thinking_wire.py
+++ b/tests/integration/providers/test_bedrock_converse_redacted_thinking_wire.py
@@ -219,7 +219,8 @@ def test_claude_redacted_thinking_round_trips_back_to_converse_as_redacted_conte
)
question: Final[dict[str, JsonValue]] = {"role": "user", "content": QUESTION}
first: Final = send(gateway, {"model": model, "messages": [question], "thinking": THINKING, "max_tokens": 2048})
- assert first.thinking_blocks == ({"type": "redacted_thinking", "data": NATIVE_REDACTED},)
+ streamed_position: Final[dict[str, JsonValue]] = {"index": 0} if stream else {}
+ assert first.thinking_blocks == ({"type": "redacted_thinking", "data": NATIVE_REDACTED, **streamed_position},)
second: Final = send(
gateway,