From 21244d8718e43da1115709cc59d2bb5ff1ba7568 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Tue, 20 Oct 2026 22:19:31 -0700 Subject: [PATCH] test(mcp): free the key's only parallel slot after a streamed auto-execute ends Run a streamed MCP auto-execute on a key with max_parallel_requests 1 on every LLM surface, then send the next request on that key and expect 200. On main both /v1/messages surfaces answer 429 here, while /v1/responses and /v1/chat/completions already pass --- .../integration/mcp/test_mcp_llm_endpoints.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/integration/mcp/test_mcp_llm_endpoints.py b/tests/integration/mcp/test_mcp_llm_endpoints.py index c5ffb88506a..79ed60f103f 100644 --- a/tests/integration/mcp/test_mcp_llm_endpoints.py +++ b/tests/integration/mcp/test_mcp_llm_endpoints.py @@ -702,6 +702,26 @@ def test_streaming_responses_opens_the_gateway_tool_call_empty_and_streams_its_a assert len(rig.upstream_tools()) == 2 +@pytest.mark.parametrize("surface", SURFACES) +def test_streamed_auto_execute_gives_back_the_keys_only_parallel_slot_once_the_stream_ends( + gateway: Gateway, surface: Surface +) -> None: + with _rig(gateway, surface) as rig: + key: Final = rig.scenario.key(object_permission={"mcp_servers": [rig.server_id]}, max_parallel_requests=1) + streamed: Final = rig.send(key, [AUTO], stream=True) + assert streamed.status_code == 200, streamed.text + assert ANSWER in streamed.text, streamed.text + assert [call["body"]["params"]["name"] for call in _peer_add_calls(rig.peer)] == ["add"] + follow_up: Final = eventually( + lambda: rig.send(key, [], prompt=f"{DIRECT} {rig.alias}"), + lambda response: response.status_code == 200, + seconds=20, + return_last_on_timeout=True, + ) + assert follow_up.status_code == 200, follow_up.text + assert rig.final_text(follow_up.json()) == ANSWER + + def test_streaming_chat_through_a_toolset_gateway_url_serves_a_team_key_without_its_own_grant( gateway: Gateway, ) -> None: