Skip to content

The agent that grows with you

test(gateway): hold only the /v1/runs task in the drain test's create_task fake

Maciej Lisiewski3b2b3fbedbbc
diff --git a/tests/gateway/test_api_server_active_work_drain.py b/tests/gateway/test_api_server_active_work_drain.py
index cd786bbce6a..ebd86c1e190 100644
--- a/tests/gateway/test_api_server_active_work_drain.py
+++ b/tests/gateway/test_api_server_active_work_drain.py
@@ -128,13 +128,22 @@ class TestDrainWaitsForApiWork:
task_started = asyncio.Event()
allow_task = asyncio.Event()
- def delayed_create_task(coro):
+ def delayed_create_task(coro, **kwargs):
+ # The patch replaces asyncio.create_task process-wide, and aiohttp >= 3.14.4
+ # schedules its own client/connector tasks through it (with eager_start=True).
+ # Hold only the /v1/runs task; everything else runs unchanged.
+ if getattr(coro, "__name__", None) not in {
+ "_execute_run",
+ "_execute_run_via_live_owner",
+ }:
+ return original_create_task(coro, **kwargs)
+
async def delayed():
task_started.set()
await allow_task.wait()
return await coro
- return original_create_task(delayed())
+ return original_create_task(delayed(), **kwargs)
mock_agent = MagicMock()
mock_agent.run_conversation.return_value = {"final_response": "done"}