fuse / data /mined /development.jsonl
ceyhunolcan's picture
Two subsets (authored, mined) with file fields as {path, content}; full dataset card with figure
db1a9ca verified
Raw History Blame Contribute Delete
228 kB
{"instance_id": "fuse-dev/starlette-3418", "repository": "https://github.com/Kludex/starlette", "license": "BSD-3-Clause", "status": "development triple: validates the pipeline; not eligible", "criterion_3": "B1: 4 of its 10 fail-to-pass tests fail without A. B2: passes without A and rewrites no line A wrote, so it does not build on A.", "snapshot_commit": "f7525198f08a6cdf5c336ecb0b9c7390142fc058", "commit_A": "99b7cc62e0c2cb8d24e5f546b7e34e17496c265e", "commit_B1": "f1dc9b630da61ee14e8b7580921a7d8f55dfa4ff", "commit_B2": "b07b8c61516307c6899ea16c8d2a00eaee3e3f84", "pull_request_A": "https://github.com/Kludex/starlette/pull/3418", "pull_request_B1": "https://github.com/Kludex/starlette/pull/3421", "pull_request_B2": "https://github.com/Kludex/starlette/pull/3420", "patch_A": "diff --git a/docs/middleware.md b/docs/middleware.md\nindex b6aa165..e3e9ad3 100644\n--- a/docs/middleware.md\n+++ b/docs/middleware.md\n@@ -242,9 +242,11 @@ The following arguments are supported:\n * `minimum_size` - Do not GZip responses that are smaller than this minimum size in bytes. Defaults to `500`.\n * `compresslevel` - Used during GZip compression. It is an integer ranging from 1 to 9. Defaults to `9`. Lower value results in faster compression but larger file sizes, while higher value results in slower compression but smaller file sizes.\n * `thread_minimum_size` - Compress body chunks at least this large in a worker thread, keeping the event loop responsive. Defaults to `131072` (128 KiB). Chunks below this size compress inline in at most a couple of milliseconds, while the fixed cost of dispatching to a worker thread would dominate.\n+* `exclude_content_types` - Content types that are never compressed. A response is excluded when its `Content-Type` media type equals one of these values, or matches a `type/*` entry like `\"image/*\"` - matching is case-insensitive and ignores parameters like `charset`. Defaults to `(\"text/event-stream\",)`, importable as `DEFAULT_EXCLUDED_CONTENT_TYPES` to extend rather than replace.\n \n-The middleware won't GZip responses that already have either a `Content-Encoding` set, to prevent them from\n-being encoded twice, or a `Content-Type` set to `text/event-stream`, to avoid compressing server-sent events.\n+The middleware won't GZip responses that already have a `Content-Encoding` set, to prevent them from being\n+encoded twice, or a `Content-Type` in `exclude_content_types` - by default `text/event-stream`, to avoid\n+compressing server-sent events.\n \n ## BaseHTTPMiddleware\n \ndiff --git a/starlette/middleware/gzip.py b/starlette/middleware/gzip.py\nindex 53ed6fd..fd17c5a 100644\n--- a/starlette/middleware/gzip.py\n+++ b/starlette/middleware/gzip.py\n@@ -3,11 +3,13 @@ from __future__ import annotations\n import zlib\n from typing import NoReturn\n \n-import anyio\n+import anyio.lowlevel\n+import anyio.to_thread\n \n from starlette.datastructures import Headers, MutableHeaders\n from starlette.types import ASGIApp, Message, Receive, Scope, Send\n \n+# TODO(v2): We should rename `DEFAULT_EXCLUDED_CONTENT_TYPES` to `DEFAULT_EXCLUDE_CONTENT_TYPES`.\n DEFAULT_EXCLUDED_CONTENT_TYPES = (\"text/event-stream\",)\n \n _gzip_capacity_limiter: anyio.lowlevel.RunVar[anyio.CapacityLimiter] = anyio.lowlevel.RunVar(\"_gzip_capacity_limiter\")\n@@ -32,11 +34,14 @@ class GZipMiddleware:\n minimum_size: int = 500,\n compresslevel: int = 9,\n thread_minimum_size: int = 128 * 1024, # 128 KiB\n+ *,\n+ exclude_content_types: tuple[str, ...] = DEFAULT_EXCLUDED_CONTENT_TYPES,\n ) -> None:\n self.app = app\n self.minimum_size = minimum_size\n self.compresslevel = compresslevel\n self.thread_minimum_size = thread_minimum_size\n+ self.exclude_content_types = _normalize_content_types(exclude_content_types)\n \n async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:\n if scope[\"type\"] != \"http\": # pragma: no cover\n@@ -51,9 +56,10 @@ class GZipMiddleware:\n self.minimum_size,\n compresslevel=self.compresslevel,\n thread_minimum_size=self.thread_minimum_size,\n+ exclude_content_types=self.exclude_content_types,\n )\n else:\n- responder = IdentityResponder(self.app, self.minimum_size)\n+ responder = IdentityResponder(self.app, self.minimum_size, exclude_content_types=self.exclude_content_types)\n \n await responder(scope, receive, send)\n \n@@ -61,9 +67,16 @@ class GZipMiddleware:\n class IdentityResponder:\n content_encoding: str\n \n- def __init__(self, app: ASGIApp, minimum_size: int) -> None:\n+ def __init__(\n+ self,\n+ app: ASGIApp,\n+ minimum_size: int,\n+ *,\n+ exclude_content_types: tuple[str, ...] = DEFAULT_EXCLUDED_CONTENT_TYPES,\n+ ) -> None:\n self.app = app\n self.minimum_size = minimum_size\n+ self.exclude_content_types = _normalize_content_types(exclude_content_types)\n self.send: Send = unattached_send\n self.initial_message: Message = {}\n self.started = False\n@@ -82,7 +95,9 @@ class IdentityResponder:\n self.initial_message = message\n headers = Headers(raw=self.initial_message[\"headers\"])\n self.content_encoding_set = \"content-encoding\" in headers\n- self.content_type_is_excluded = headers.get(\"content-type\", \"\").startswith(DEFAULT_EXCLUDED_CONTENT_TYPES)\n+ media_type = headers.get(\"content-type\", \"\").partition(\";\")[0].strip().lower()\n+ media_types = {media_type, media_type.partition(\"/\")[0] + \"/*\"}\n+ self.content_type_is_excluded = not media_types.isdisjoint(self.exclude_content_types)\n elif message_type == \"http.response.body\" and (self.content_encoding_set or self.content_type_is_excluded):\n if not self.started:\n self.started = True\n@@ -154,8 +169,9 @@ class GZipResponder(IdentityResponder):\n compresslevel: int = 9,\n *,\n thread_minimum_size: int = 128 * 1024, # 128 KiB\n+ exclude_content_types: tuple[str, ...] = DEFAULT_EXCLUDED_CONTENT_TYPES,\n ) -> None:\n- super().__init__(app, minimum_size)\n+ super().__init__(app, minimum_size, exclude_content_types=exclude_content_types)\n \n self.compresslevel = compresslevel\n self.thread_minimum_size = thread_minimum_size\n@@ -182,3 +198,7 @@ class GZipResponder(IdentityResponder):\n \n async def unattached_send(message: Message) -> NoReturn:\n raise RuntimeError(\"send awaitable not set\") # pragma: no cover\n+\n+\n+def _normalize_content_types(content_types: tuple[str, ...]) -> tuple[str, ...]:\n+ return tuple(content_type.partition(\";\")[0].strip().lower() for content_type in content_types)\ndiff --git a/tests/middleware/test_gzip.py b/tests/middleware/test_gzip.py\nindex 7adf2b3..1ceddca 100644\n--- a/tests/middleware/test_gzip.py\n+++ b/tests/middleware/test_gzip.py\n@@ -7,7 +7,7 @@ import pytest\n \n from starlette.applications import Starlette\n from starlette.middleware import Middleware\n-from starlette.middleware.gzip import GZipMiddleware\n+from starlette.middleware.gzip import GZipMiddleware, GZipResponder\n from starlette.requests import Request\n from starlette.responses import ContentStream, FileResponse, PlainTextResponse, StreamingResponse\n from starlette.routing import Route\n@@ -239,3 +239,87 @@ async def test_gzip_ignored_for_pathsend_responses(tmpdir: Path) -> None:\n assert len(events) == 2\n assert events[0][\"type\"] == \"http.response.start\"\n assert events[1][\"type\"] == \"http.response.pathsend\"\n+\n+\n+def test_gzip_custom_exclude_content_types(test_client_factory: TestClientFactory) -> None:\n+ async def app(scope: Scope, receive: Receive, send: Send) -> None:\n+ await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/zip\")]})\n+ await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n+\n+ middleware = GZipMiddleware(app, exclude_content_types=(\"application/zip\",))\n+\n+ client = test_client_factory(middleware)\n+ response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n+ assert response.status_code == 200\n+ assert response.content == b\"x\" * 4000\n+ assert \"Content-Encoding\" not in response.headers\n+ assert \"Vary\" not in response.headers\n+\n+\n+def test_gzip_cleared_exclude_content_types(test_client_factory: TestClientFactory) -> None:\n+ async def app(scope: Scope, receive: Receive, send: Send) -> None:\n+ await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"text/event-stream\")]})\n+ await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n+\n+ middleware = GZipMiddleware(app, exclude_content_types=())\n+\n+ client = test_client_factory(middleware)\n+ response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n+ assert response.status_code == 200\n+ assert response.content == b\"x\" * 4000\n+ assert response.headers[\"Content-Encoding\"] == \"gzip\"\n+ assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n+\n+\n+def test_gzip_exclude_content_types_for_identity_client(test_client_factory: TestClientFactory) -> None:\n+ async def app(scope: Scope, receive: Receive, send: Send) -> None:\n+ await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/zip\")]})\n+ await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n+\n+ middleware = GZipMiddleware(app, exclude_content_types=(\"application/zip\",))\n+\n+ client = test_client_factory(middleware)\n+ response = client.get(\"/\", headers={\"accept-encoding\": \"identity\"})\n+ assert response.status_code == 200\n+ assert response.content == b\"x\" * 4000\n+ assert \"Content-Encoding\" not in response.headers\n+ assert \"Vary\" not in response.headers\n+\n+\n+@pytest.mark.parametrize(\n+ (\"exclude_content_types\", \"content_type\"),\n+ [\n+ pytest.param((\"text/event-stream\",), b\"Text/Event-Stream; charset=utf-8\", id=\"header-is-normalized\"),\n+ pytest.param((\"Application/ZIP; charset=utf-8\",), b\"application/zip\", id=\"configured-value-is-normalized\"),\n+ pytest.param((\"image/*\",), b\"image/png\", id=\"wildcard\"),\n+ ],\n+)\n+def test_gzip_exclude_content_types_matching(\n+ exclude_content_types: tuple[str, ...], content_type: bytes, test_client_factory: TestClientFactory\n+) -> None:\n+ async def app(scope: Scope, receive: Receive, send: Send) -> None:\n+ await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", content_type)]})\n+ await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n+\n+ middleware = GZipMiddleware(app, exclude_content_types=exclude_content_types)\n+\n+ client = test_client_factory(middleware)\n+ response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n+ assert response.status_code == 200\n+ assert response.content == b\"x\" * 4000\n+ assert \"Content-Encoding\" not in response.headers\n+ assert \"Vary\" not in response.headers\n+\n+\n+def test_gzip_responder_normalizes_content_types(test_client_factory: TestClientFactory) -> None:\n+ async def app(scope: Scope, receive: Receive, send: Send) -> None:\n+ await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/zip\")]})\n+ await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n+\n+ responder = GZipResponder(app, 500, exclude_content_types=(\"Application/ZIP; charset=utf-8\",))\n+\n+ client = test_client_factory(responder)\n+ response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n+ assert response.status_code == 200\n+ assert response.content == b\"x\" * 4000\n+ assert \"Content-Encoding\" not in response.headers\n", "patch_B1": "diff --git a/docs/middleware.md b/docs/middleware.md\nindex e3e9ad3..06d7e68 100644\n--- a/docs/middleware.md\n+++ b/docs/middleware.md\n@@ -242,11 +242,12 @@ The following arguments are supported:\n * `minimum_size` - Do not GZip responses that are smaller than this minimum size in bytes. Defaults to `500`.\n * `compresslevel` - Used during GZip compression. It is an integer ranging from 1 to 9. Defaults to `9`. Lower value results in faster compression but larger file sizes, while higher value results in slower compression but smaller file sizes.\n * `thread_minimum_size` - Compress body chunks at least this large in a worker thread, keeping the event loop responsive. Defaults to `131072` (128 KiB). Chunks below this size compress inline in at most a couple of milliseconds, while the fixed cost of dispatching to a worker thread would dominate.\n-* `exclude_content_types` - Content types that are never compressed. A response is excluded when its `Content-Type` media type equals one of these values, or matches a `type/*` entry like `\"image/*\"` - matching is case-insensitive and ignores parameters like `charset`. Defaults to `(\"text/event-stream\",)`, importable as `DEFAULT_EXCLUDED_CONTENT_TYPES` to extend rather than replace.\n+* `exclude_content_types` - Content types that are never compressed. A response is excluded when its `Content-Type` media type equals one of these values, or matches a `type/*` entry like `\"image/*\"` - matching is case-insensitive and ignores parameters like `charset`. Defaults to `DEFAULT_EXCLUDED_CONTENT_TYPES` (importable, to extend rather than replace): `text/event-stream` plus already-compressed formats - zip and gzip archives, common raster image types, `video/*`, `audio/*`, and WOFF fonts. `image/svg+xml` is deliberately not excluded, since SVG is text and compresses well.\n \n The middleware won't GZip responses that already have a `Content-Encoding` set, to prevent them from being\n encoded twice, or a `Content-Type` in `exclude_content_types` - by default `text/event-stream`, to avoid\n-compressing server-sent events.\n+compressing server-sent events, and already-compressed formats, where compression wastes CPU for no\n+gain.\n \n ## BaseHTTPMiddleware\n \ndiff --git a/starlette/middleware/gzip.py b/starlette/middleware/gzip.py\nindex fd17c5a..a6271b7 100644\n--- a/starlette/middleware/gzip.py\n+++ b/starlette/middleware/gzip.py\n@@ -10,7 +10,21 @@ from starlette.datastructures import Headers, MutableHeaders\n from starlette.types import ASGIApp, Message, Receive, Scope, Send\n \n # TODO(v2): We should rename `DEFAULT_EXCLUDED_CONTENT_TYPES` to `DEFAULT_EXCLUDE_CONTENT_TYPES`.\n-DEFAULT_EXCLUDED_CONTENT_TYPES = (\"text/event-stream\",)\n+DEFAULT_EXCLUDED_CONTENT_TYPES = (\n+ \"application/gzip\",\n+ \"application/x-gzip\",\n+ \"application/zip\",\n+ \"audio/*\",\n+ \"font/woff\",\n+ \"font/woff2\",\n+ \"image/avif\",\n+ \"image/gif\",\n+ \"image/jpeg\",\n+ \"image/png\",\n+ \"image/webp\",\n+ \"text/event-stream\",\n+ \"video/*\",\n+)\n \n _gzip_capacity_limiter: anyio.lowlevel.RunVar[anyio.CapacityLimiter] = anyio.lowlevel.RunVar(\"_gzip_capacity_limiter\")\n \ndiff --git a/tests/middleware/test_gzip.py b/tests/middleware/test_gzip.py\nindex 1ceddca..1295916 100644\n--- a/tests/middleware/test_gzip.py\n+++ b/tests/middleware/test_gzip.py\n@@ -241,6 +241,40 @@ async def test_gzip_ignored_for_pathsend_responses(tmpdir: Path) -> None:\n assert events[1][\"type\"] == \"http.response.pathsend\"\n \n \n+@pytest.mark.parametrize(\n+ \"content_type\",\n+ [b\"application/zip\", b\"audio/mpeg\", b\"font/woff2\", b\"image/png\", b\"video/mp4\"],\n+)\n+def test_gzip_default_exclude_content_types(content_type: bytes, test_client_factory: TestClientFactory) -> None:\n+ async def app(scope: Scope, receive: Receive, send: Send) -> None:\n+ await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", content_type)]})\n+ await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n+\n+ middleware = GZipMiddleware(app)\n+\n+ client = test_client_factory(middleware)\n+ response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n+ assert response.status_code == 200\n+ assert response.content == b\"x\" * 4000\n+ assert \"Content-Encoding\" not in response.headers\n+ assert \"Vary\" not in response.headers\n+\n+\n+def test_gzip_compresses_svg_by_default(test_client_factory: TestClientFactory) -> None:\n+ async def app(scope: Scope, receive: Receive, send: Send) -> None:\n+ await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"image/svg+xml\")]})\n+ await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n+\n+ middleware = GZipMiddleware(app)\n+\n+ client = test_client_factory(middleware)\n+ response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n+ assert response.status_code == 200\n+ assert response.content == b\"x\" * 4000\n+ assert response.headers[\"Content-Encoding\"] == \"gzip\"\n+ assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n+\n+\n def test_gzip_custom_exclude_content_types(test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/zip\")]})\n", "patch_B2": "diff --git a/docs/middleware.md b/docs/middleware.md\nindex e3e9ad3..20ef640 100644\n--- a/docs/middleware.md\n+++ b/docs/middleware.md\n@@ -245,8 +245,9 @@ The following arguments are supported:\n * `exclude_content_types` - Content types that are never compressed. A response is excluded when its `Content-Type` media type equals one of these values, or matches a `type/*` entry like `\"image/*\"` - matching is case-insensitive and ignores parameters like `charset`. Defaults to `(\"text/event-stream\",)`, importable as `DEFAULT_EXCLUDED_CONTENT_TYPES` to extend rather than replace.\n \n The middleware won't GZip responses that already have a `Content-Encoding` set, to prevent them from being\n-encoded twice, or a `Content-Type` in `exclude_content_types` - by default `text/event-stream`, to avoid\n-compressing server-sent events.\n+encoded twice, partial content responses (status `206`), to keep range semantics\n+intact, or responses with a `Content-Type` in `exclude_content_types` - by default `text/event-stream`, to\n+avoid compressing server-sent events.\n \n ## BaseHTTPMiddleware\n \ndiff --git a/starlette/middleware/gzip.py b/starlette/middleware/gzip.py\nindex fd17c5a..60f7dd7 100644\n--- a/starlette/middleware/gzip.py\n+++ b/starlette/middleware/gzip.py\n@@ -82,6 +82,7 @@ class IdentityResponder:\n self.started = False\n self.content_encoding_set = False\n self.content_type_is_excluded = False\n+ self.partial_response = False\n \n async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:\n self.send = send\n@@ -95,10 +96,13 @@ class IdentityResponder:\n self.initial_message = message\n headers = Headers(raw=self.initial_message[\"headers\"])\n self.content_encoding_set = \"content-encoding\" in headers\n+ self.partial_response = message[\"status\"] == 206\n media_type = headers.get(\"content-type\", \"\").partition(\";\")[0].strip().lower()\n media_types = {media_type, media_type.partition(\"/\")[0] + \"/*\"}\n self.content_type_is_excluded = not media_types.isdisjoint(self.exclude_content_types)\n- elif message_type == \"http.response.body\" and (self.content_encoding_set or self.content_type_is_excluded):\n+ elif message_type == \"http.response.body\" and (\n+ self.content_encoding_set or self.partial_response or self.content_type_is_excluded\n+ ):\n if not self.started:\n self.started = True\n await self.send(self.initial_message)\ndiff --git a/tests/middleware/test_gzip.py b/tests/middleware/test_gzip.py\nindex 1ceddca..ccd6882 100644\n--- a/tests/middleware/test_gzip.py\n+++ b/tests/middleware/test_gzip.py\n@@ -241,6 +241,26 @@ async def test_gzip_ignored_for_pathsend_responses(tmpdir: Path) -> None:\n assert events[1][\"type\"] == \"http.response.pathsend\"\n \n \n+def test_gzip_ignored_on_range_responses(tmp_path: Path, test_client_factory: TestClientFactory) -> None:\n+ path = tmp_path / \"example.txt\"\n+ path.write_text(\"x\" * 4000)\n+\n+ def homepage(request: Request) -> FileResponse:\n+ return FileResponse(path)\n+\n+ app = Starlette(\n+ routes=[Route(\"/\", endpoint=homepage)],\n+ middleware=[Middleware(GZipMiddleware)],\n+ )\n+\n+ client = test_client_factory(app)\n+ response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\", \"range\": \"bytes=0-1999\"})\n+ assert response.status_code == 206\n+ assert response.content == b\"x\" * 2000\n+ assert \"Content-Encoding\" not in response.headers\n+ assert int(response.headers[\"Content-Length\"]) == 2000\n+\n+\n def test_gzip_custom_exclude_content_types(test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/zip\")]})\n", "patch_B1_upstream": "diff --git a/docs/middleware.md b/docs/middleware.md\nindex 841afd0..cdb523c 100644\n--- a/docs/middleware.md\n+++ b/docs/middleware.md\n@@ -241,12 +241,13 @@ The following arguments are supported:\n * `minimum_size` - Do not GZip responses that are smaller than this minimum size in bytes. Defaults to `500`.\n * `compresslevel` - Used during GZip compression. It is an integer ranging from 1 to 9. Defaults to `9`. Lower value results in faster compression but larger file sizes, while higher value results in slower compression but smaller file sizes.\n * `thread_minimum_size` - Compress body chunks at least this large in a worker thread, keeping the event loop responsive. Defaults to `131072` (128 KiB). Chunks below this size compress inline in at most a couple of milliseconds, while the fixed cost of dispatching to a worker thread would dominate.\n-* `exclude_content_types` - Content types that are never compressed. A response is excluded when its `Content-Type` media type equals one of these values, or matches a `type/*` entry like `\"image/*\"` - matching is case-insensitive and ignores parameters like `charset`. Defaults to `(\"text/event-stream\",)`, importable as `DEFAULT_EXCLUDED_CONTENT_TYPES` to extend rather than replace.\n+* `exclude_content_types` - Content types that are never compressed. A response is excluded when its `Content-Type` media type equals one of these values, or matches a `type/*` entry like `\"image/*\"` - matching is case-insensitive and ignores parameters like `charset`. Defaults to `DEFAULT_EXCLUDED_CONTENT_TYPES` (importable, to extend rather than replace): `text/event-stream` plus already-compressed formats - zip and gzip archives, common raster image types, `video/*`, `audio/*`, and WOFF fonts. `image/svg+xml` is deliberately not excluded, since SVG is text and compresses well.\n \n The middleware won't GZip responses that already have a `Content-Encoding` set, to prevent them from being\n encoded twice, partial content responses (status `206`), to keep range semantics\n intact, or responses with a `Content-Type` in `exclude_content_types` - by default `text/event-stream`, to\n-avoid compressing server-sent events.\n+avoid compressing server-sent events, and already-compressed formats, where compression wastes CPU for no\n+gain.\n \n ## BaseHTTPMiddleware\n \ndiff --git a/starlette/middleware/gzip.py b/starlette/middleware/gzip.py\nindex 7b4003a..4473f5a 100644\n--- a/starlette/middleware/gzip.py\n+++ b/starlette/middleware/gzip.py\n@@ -10,7 +10,21 @@ from starlette.datastructures import Headers, MutableHeaders\n from starlette.types import ASGIApp, Message, Receive, Scope, Send\n \n # TODO(v2): We should rename `DEFAULT_EXCLUDED_CONTENT_TYPES` to `DEFAULT_EXCLUDE_CONTENT_TYPES`.\n-DEFAULT_EXCLUDED_CONTENT_TYPES = (\"text/event-stream\",)\n+DEFAULT_EXCLUDED_CONTENT_TYPES = (\n+ \"application/gzip\",\n+ \"application/x-gzip\",\n+ \"application/zip\",\n+ \"audio/*\",\n+ \"font/woff\",\n+ \"font/woff2\",\n+ \"image/avif\",\n+ \"image/gif\",\n+ \"image/jpeg\",\n+ \"image/png\",\n+ \"image/webp\",\n+ \"text/event-stream\",\n+ \"video/*\",\n+)\n \n _gzip_capacity_limiter: anyio.lowlevel.RunVar[anyio.CapacityLimiter] = anyio.lowlevel.RunVar(\"_gzip_capacity_limiter\")\n \ndiff --git a/tests/middleware/test_gzip.py b/tests/middleware/test_gzip.py\nindex c84a911..6574259 100644\n--- a/tests/middleware/test_gzip.py\n+++ b/tests/middleware/test_gzip.py\n@@ -308,6 +308,40 @@ def test_gzip_streaming_response_emits_output_per_chunk(test_client_factory: Tes\n assert decompressor.eof\n \n \n+@pytest.mark.parametrize(\n+ \"content_type\",\n+ [b\"application/zip\", b\"audio/mpeg\", b\"font/woff2\", b\"image/png\", b\"video/mp4\"],\n+)\n+def test_gzip_default_exclude_content_types(content_type: bytes, test_client_factory: TestClientFactory) -> None:\n+ async def app(scope: Scope, receive: Receive, send: Send) -> None:\n+ await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", content_type)]})\n+ await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n+\n+ middleware = GZipMiddleware(app)\n+\n+ client = test_client_factory(middleware)\n+ response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n+ assert response.status_code == 200\n+ assert response.content == b\"x\" * 4000\n+ assert \"Content-Encoding\" not in response.headers\n+ assert \"Vary\" not in response.headers\n+\n+\n+def test_gzip_compresses_svg_by_default(test_client_factory: TestClientFactory) -> None:\n+ async def app(scope: Scope, receive: Receive, send: Send) -> None:\n+ await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"image/svg+xml\")]})\n+ await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n+\n+ middleware = GZipMiddleware(app)\n+\n+ client = test_client_factory(middleware)\n+ response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n+ assert response.status_code == 200\n+ assert response.content == b\"x\" * 4000\n+ assert response.headers[\"Content-Encoding\"] == \"gzip\"\n+ assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n+\n+\n def test_gzip_custom_exclude_content_types(test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/zip\")]})\n", "patch_B2_upstream": "diff --git a/docs/middleware.md b/docs/middleware.md\nindex 9d6c1cf..841afd0 100644\n--- a/docs/middleware.md\n+++ b/docs/middleware.md\n@@ -244,8 +244,9 @@ The following arguments are supported:\n * `exclude_content_types` - Content types that are never compressed. A response is excluded when its `Content-Type` media type equals one of these values, or matches a `type/*` entry like `\"image/*\"` - matching is case-insensitive and ignores parameters like `charset`. Defaults to `(\"text/event-stream\",)`, importable as `DEFAULT_EXCLUDED_CONTENT_TYPES` to extend rather than replace.\n \n The middleware won't GZip responses that already have a `Content-Encoding` set, to prevent them from being\n-encoded twice, or a `Content-Type` in `exclude_content_types` - by default `text/event-stream`, to avoid\n-compressing server-sent events.\n+encoded twice, partial content responses (status `206`), to keep range semantics\n+intact, or responses with a `Content-Type` in `exclude_content_types` - by default `text/event-stream`, to\n+avoid compressing server-sent events.\n \n ## BaseHTTPMiddleware\n \ndiff --git a/starlette/middleware/gzip.py b/starlette/middleware/gzip.py\nindex 4deedde..7b4003a 100644\n--- a/starlette/middleware/gzip.py\n+++ b/starlette/middleware/gzip.py\n@@ -82,6 +82,7 @@ class IdentityResponder:\n self.started = False\n self.content_encoding_set = False\n self.content_type_is_excluded = False\n+ self.partial_response = False\n \n async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:\n self.send = send\n@@ -95,10 +96,13 @@ class IdentityResponder:\n self.initial_message = message\n headers = Headers(raw=self.initial_message[\"headers\"])\n self.content_encoding_set = \"content-encoding\" in headers\n+ self.partial_response = message[\"status\"] == 206\n media_type = headers.get(\"content-type\", \"\").partition(\";\")[0].strip().lower()\n media_types = {media_type, media_type.partition(\"/\")[0] + \"/*\"}\n self.content_type_is_excluded = not media_types.isdisjoint(self.exclude_content_types)\n- elif message_type == \"http.response.body\" and (self.content_encoding_set or self.content_type_is_excluded):\n+ elif message_type == \"http.response.body\" and (\n+ self.content_encoding_set or self.partial_response or self.content_type_is_excluded\n+ ):\n if not self.started:\n self.started = True\n await self.send(self.initial_message)\ndiff --git a/tests/middleware/test_gzip.py b/tests/middleware/test_gzip.py\nindex a91a19c..c84a911 100644\n--- a/tests/middleware/test_gzip.py\n+++ b/tests/middleware/test_gzip.py\n@@ -255,6 +255,26 @@ async def test_gzip_ignored_for_pathsend_responses(tmpdir: Path) -> None:\n assert events[1][\"type\"] == \"http.response.pathsend\"\n \n \n+def test_gzip_ignored_on_range_responses(tmp_path: Path, test_client_factory: TestClientFactory) -> None:\n+ path = tmp_path / \"example.txt\"\n+ path.write_text(\"x\" * 4000)\n+\n+ def homepage(request: Request) -> FileResponse:\n+ return FileResponse(path)\n+\n+ app = Starlette(\n+ routes=[Route(\"/\", endpoint=homepage)],\n+ middleware=[Middleware(GZipMiddleware)],\n+ )\n+\n+ client = test_client_factory(app)\n+ response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\", \"range\": \"bytes=0-1999\"})\n+ assert response.status_code == 206\n+ assert response.content == b\"x\" * 2000\n+ assert \"Content-Encoding\" not in response.headers\n+ assert int(response.headers[\"Content-Length\"]) == 2000\n+\n+\n def test_gzip_streaming_response_emits_output_per_chunk(test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"text/plain\")]})\n", "tests_A": [{"path": "tests/middleware/test_gzip.py", "content": "from __future__ import annotations\n\nimport hashlib\nfrom pathlib import Path\n\nimport pytest\n\nfrom starlette.applications import Starlette\nfrom starlette.middleware import Middleware\nfrom starlette.middleware.gzip import GZipMiddleware, GZipResponder\nfrom starlette.requests import Request\nfrom starlette.responses import ContentStream, FileResponse, PlainTextResponse, StreamingResponse\nfrom starlette.routing import Route\nfrom starlette.types import Message, Receive, Scope, Send\nfrom tests.types import TestClientFactory\n\n\ndef test_gzip_responses(test_client_factory: TestClientFactory) -> None:\n def homepage(request: Request) -> PlainTextResponse:\n return PlainTextResponse(\"x\" * 4000, status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert response.headers[\"Content-Encoding\"] == \"gzip\"\n assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n assert int(response.headers[\"Content-Length\"]) < 4000\n\n\ndef test_gzip_not_in_accept_encoding(test_client_factory: TestClientFactory) -> None:\n def homepage(request: Request) -> PlainTextResponse:\n return PlainTextResponse(\"x\" * 4000, status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"identity\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n assert int(response.headers[\"Content-Length\"]) == 4000\n\n\ndef test_gzip_ignored_for_small_responses(\n test_client_factory: TestClientFactory,\n) -> None:\n def homepage(request: Request) -> PlainTextResponse:\n return PlainTextResponse(\"OK\", status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.text == \"OK\"\n assert \"Content-Encoding\" not in response.headers\n assert \"Vary\" not in response.headers\n assert int(response.headers[\"Content-Length\"]) == 2\n\n\ndef test_gzip_streaming_response(test_client_factory: TestClientFactory) -> None:\n def homepage(request: Request) -> StreamingResponse:\n async def generator(bytes: bytes, count: int) -> ContentStream:\n for index in range(count):\n yield bytes\n\n streaming = generator(bytes=b\"x\" * 400, count=10)\n return StreamingResponse(streaming, status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert response.headers[\"Content-Encoding\"] == \"gzip\"\n assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n assert \"Content-Length\" not in response.headers\n\n\ndef test_gzip_compression_in_thread(test_client_factory: TestClientFactory) -> None:\n payload = \"x\" * (128 * 1024)\n\n def homepage(request: Request) -> PlainTextResponse:\n return PlainTextResponse(payload, status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n # Ensure the response body takes the worker-thread compression path.\n middleware=[Middleware(GZipMiddleware, thread_minimum_size=len(payload))],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.text == payload\n assert response.headers[\"Content-Encoding\"] == \"gzip\"\n assert int(response.headers[\"Content-Length\"]) < len(payload)\n\n\ndef test_gzip_streaming_compression_in_thread(test_client_factory: TestClientFactory) -> None:\n chunk = hashlib.shake_256(b\"starlette-gzip-stream\").digest(256 * 1024)\n\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/json\")]})\n await send({\"type\": \"http.response.body\", \"body\": chunk, \"more_body\": True})\n await send({\"type\": \"http.response.body\", \"body\": b\"tail\"})\n\n # Ensure the streamed chunk takes the worker-thread compression path.\n middleware = GZipMiddleware(app, thread_minimum_size=len(chunk))\n\n client = test_client_factory(middleware)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.content == chunk + b\"tail\"\n assert response.headers[\"Content-Encoding\"] == \"gzip\"\n\n\ndef test_gzip_streaming_response_identity(test_client_factory: TestClientFactory) -> None:\n def homepage(request: Request) -> StreamingResponse:\n async def generator(bytes: bytes, count: int) -> ContentStream:\n for index in range(count):\n yield bytes\n\n streaming = generator(bytes=b\"x\" * 400, count=10)\n return StreamingResponse(streaming, status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"identity\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n assert \"Content-Length\" not in response.headers\n\n\ndef test_gzip_ignored_for_responses_with_encoding_set(\n test_client_factory: TestClientFactory,\n) -> None:\n def homepage(request: Request) -> StreamingResponse:\n async def generator(bytes: bytes, count: int) -> ContentStream:\n for index in range(count):\n yield bytes\n\n streaming = generator(bytes=b\"x\" * 400, count=10)\n return StreamingResponse(streaming, status_code=200, headers={\"Content-Encoding\": \"text\"})\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip, text\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert response.headers[\"Content-Encoding\"] == \"text\"\n assert \"Vary\" not in response.headers\n assert \"Content-Length\" not in response.headers\n\n\ndef test_gzip_ignored_on_server_sent_events(test_client_factory: TestClientFactory) -> None:\n def homepage(request: Request) -> StreamingResponse:\n async def generator(bytes: bytes, count: int) -> ContentStream:\n for _ in range(count):\n yield bytes\n\n streaming = generator(bytes=b\"x\" * 400, count=10)\n return StreamingResponse(streaming, status_code=200, media_type=\"text/event-stream\")\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert \"Content-Length\" not in response.headers\n\n\n@pytest.mark.anyio\nasync def test_gzip_ignored_for_pathsend_responses(tmpdir: Path) -> None:\n path = tmpdir / \"example.txt\"\n with path.open(\"w\") as file:\n file.write(\"<file content>\")\n\n events: list[Message] = []\n\n async def endpoint_with_pathsend(request: Request) -> FileResponse:\n _ = await request.body()\n return FileResponse(path)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=endpoint_with_pathsend)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n scope = {\n \"type\": \"http\",\n \"version\": \"3\",\n \"method\": \"GET\",\n \"path\": \"/\",\n \"headers\": [(b\"accept-encoding\", b\"gzip, text\")],\n \"extensions\": {\"http.response.pathsend\": {}},\n }\n\n async def receive() -> Message:\n return {\"type\": \"http.request\", \"body\": b\"\", \"more_body\": False}\n\n async def send(message: Message) -> None:\n events.append(message)\n\n await app(scope, receive, send)\n\n assert len(events) == 2\n assert events[0][\"type\"] == \"http.response.start\"\n assert events[1][\"type\"] == \"http.response.pathsend\"\n\n\ndef test_gzip_custom_exclude_content_types(test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/zip\")]})\n await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n\n middleware = GZipMiddleware(app, exclude_content_types=(\"application/zip\",))\n\n client = test_client_factory(middleware)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.content == b\"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert \"Vary\" not in response.headers\n\n\ndef test_gzip_cleared_exclude_content_types(test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"text/event-stream\")]})\n await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n\n middleware = GZipMiddleware(app, exclude_content_types=())\n\n client = test_client_factory(middleware)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.content == b\"x\" * 4000\n assert response.headers[\"Content-Encoding\"] == \"gzip\"\n assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n\n\ndef test_gzip_exclude_content_types_for_identity_client(test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/zip\")]})\n await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n\n middleware = GZipMiddleware(app, exclude_content_types=(\"application/zip\",))\n\n client = test_client_factory(middleware)\n response = client.get(\"/\", headers={\"accept-encoding\": \"identity\"})\n assert response.status_code == 200\n assert response.content == b\"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert \"Vary\" not in response.headers\n\n\n@pytest.mark.parametrize(\n (\"exclude_content_types\", \"content_type\"),\n [\n pytest.param((\"text/event-stream\",), b\"Text/Event-Stream; charset=utf-8\", id=\"header-is-normalized\"),\n pytest.param((\"Application/ZIP; charset=utf-8\",), b\"application/zip\", id=\"configured-value-is-normalized\"),\n pytest.param((\"image/*\",), b\"image/png\", id=\"wildcard\"),\n ],\n)\ndef test_gzip_exclude_content_types_matching(\n exclude_content_types: tuple[str, ...], content_type: bytes, test_client_factory: TestClientFactory\n) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", content_type)]})\n await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n\n middleware = GZipMiddleware(app, exclude_content_types=exclude_content_types)\n\n client = test_client_factory(middleware)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.content == b\"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert \"Vary\" not in response.headers\n\n\ndef test_gzip_responder_normalizes_content_types(test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/zip\")]})\n await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n\n responder = GZipResponder(app, 500, exclude_content_types=(\"Application/ZIP; charset=utf-8\",))\n\n client = test_client_factory(responder)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.content == b\"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n"}], "tests_B1": [{"path": "tests/middleware/test_gzip.py", "content": "from __future__ import annotations\n\nimport hashlib\nfrom pathlib import Path\n\nimport pytest\n\nfrom starlette.applications import Starlette\nfrom starlette.middleware import Middleware\nfrom starlette.middleware.gzip import GZipMiddleware, GZipResponder\nfrom starlette.requests import Request\nfrom starlette.responses import ContentStream, FileResponse, PlainTextResponse, StreamingResponse\nfrom starlette.routing import Route\nfrom starlette.types import Message, Receive, Scope, Send\nfrom tests.types import TestClientFactory\n\n\ndef test_gzip_responses(test_client_factory: TestClientFactory) -> None:\n def homepage(request: Request) -> PlainTextResponse:\n return PlainTextResponse(\"x\" * 4000, status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert response.headers[\"Content-Encoding\"] == \"gzip\"\n assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n assert int(response.headers[\"Content-Length\"]) < 4000\n\n\ndef test_gzip_not_in_accept_encoding(test_client_factory: TestClientFactory) -> None:\n def homepage(request: Request) -> PlainTextResponse:\n return PlainTextResponse(\"x\" * 4000, status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"identity\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n assert int(response.headers[\"Content-Length\"]) == 4000\n\n\ndef test_gzip_ignored_for_small_responses(\n test_client_factory: TestClientFactory,\n) -> None:\n def homepage(request: Request) -> PlainTextResponse:\n return PlainTextResponse(\"OK\", status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.text == \"OK\"\n assert \"Content-Encoding\" not in response.headers\n assert \"Vary\" not in response.headers\n assert int(response.headers[\"Content-Length\"]) == 2\n\n\ndef test_gzip_streaming_response(test_client_factory: TestClientFactory) -> None:\n def homepage(request: Request) -> StreamingResponse:\n async def generator(bytes: bytes, count: int) -> ContentStream:\n for index in range(count):\n yield bytes\n\n streaming = generator(bytes=b\"x\" * 400, count=10)\n return StreamingResponse(streaming, status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert response.headers[\"Content-Encoding\"] == \"gzip\"\n assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n assert \"Content-Length\" not in response.headers\n\n\ndef test_gzip_compression_in_thread(test_client_factory: TestClientFactory) -> None:\n payload = \"x\" * (128 * 1024)\n\n def homepage(request: Request) -> PlainTextResponse:\n return PlainTextResponse(payload, status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n # Ensure the response body takes the worker-thread compression path.\n middleware=[Middleware(GZipMiddleware, thread_minimum_size=len(payload))],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.text == payload\n assert response.headers[\"Content-Encoding\"] == \"gzip\"\n assert int(response.headers[\"Content-Length\"]) < len(payload)\n\n\ndef test_gzip_streaming_compression_in_thread(test_client_factory: TestClientFactory) -> None:\n chunk = hashlib.shake_256(b\"starlette-gzip-stream\").digest(256 * 1024)\n\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/json\")]})\n await send({\"type\": \"http.response.body\", \"body\": chunk, \"more_body\": True})\n await send({\"type\": \"http.response.body\", \"body\": b\"tail\"})\n\n # Ensure the streamed chunk takes the worker-thread compression path.\n middleware = GZipMiddleware(app, thread_minimum_size=len(chunk))\n\n client = test_client_factory(middleware)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.content == chunk + b\"tail\"\n assert response.headers[\"Content-Encoding\"] == \"gzip\"\n\n\ndef test_gzip_streaming_response_identity(test_client_factory: TestClientFactory) -> None:\n def homepage(request: Request) -> StreamingResponse:\n async def generator(bytes: bytes, count: int) -> ContentStream:\n for index in range(count):\n yield bytes\n\n streaming = generator(bytes=b\"x\" * 400, count=10)\n return StreamingResponse(streaming, status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"identity\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n assert \"Content-Length\" not in response.headers\n\n\ndef test_gzip_ignored_for_responses_with_encoding_set(\n test_client_factory: TestClientFactory,\n) -> None:\n def homepage(request: Request) -> StreamingResponse:\n async def generator(bytes: bytes, count: int) -> ContentStream:\n for index in range(count):\n yield bytes\n\n streaming = generator(bytes=b\"x\" * 400, count=10)\n return StreamingResponse(streaming, status_code=200, headers={\"Content-Encoding\": \"text\"})\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip, text\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert response.headers[\"Content-Encoding\"] == \"text\"\n assert \"Vary\" not in response.headers\n assert \"Content-Length\" not in response.headers\n\n\ndef test_gzip_ignored_on_server_sent_events(test_client_factory: TestClientFactory) -> None:\n def homepage(request: Request) -> StreamingResponse:\n async def generator(bytes: bytes, count: int) -> ContentStream:\n for _ in range(count):\n yield bytes\n\n streaming = generator(bytes=b\"x\" * 400, count=10)\n return StreamingResponse(streaming, status_code=200, media_type=\"text/event-stream\")\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert \"Content-Length\" not in response.headers\n\n\n@pytest.mark.anyio\nasync def test_gzip_ignored_for_pathsend_responses(tmpdir: Path) -> None:\n path = tmpdir / \"example.txt\"\n with path.open(\"w\") as file:\n file.write(\"<file content>\")\n\n events: list[Message] = []\n\n async def endpoint_with_pathsend(request: Request) -> FileResponse:\n _ = await request.body()\n return FileResponse(path)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=endpoint_with_pathsend)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n scope = {\n \"type\": \"http\",\n \"version\": \"3\",\n \"method\": \"GET\",\n \"path\": \"/\",\n \"headers\": [(b\"accept-encoding\", b\"gzip, text\")],\n \"extensions\": {\"http.response.pathsend\": {}},\n }\n\n async def receive() -> Message:\n return {\"type\": \"http.request\", \"body\": b\"\", \"more_body\": False}\n\n async def send(message: Message) -> None:\n events.append(message)\n\n await app(scope, receive, send)\n\n assert len(events) == 2\n assert events[0][\"type\"] == \"http.response.start\"\n assert events[1][\"type\"] == \"http.response.pathsend\"\n\n\n@pytest.mark.parametrize(\n \"content_type\",\n [b\"application/zip\", b\"audio/mpeg\", b\"font/woff2\", b\"image/png\", b\"video/mp4\"],\n)\ndef test_gzip_default_exclude_content_types(content_type: bytes, test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", content_type)]})\n await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n\n middleware = GZipMiddleware(app)\n\n client = test_client_factory(middleware)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.content == b\"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert \"Vary\" not in response.headers\n\n\ndef test_gzip_compresses_svg_by_default(test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"image/svg+xml\")]})\n await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n\n middleware = GZipMiddleware(app)\n\n client = test_client_factory(middleware)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.content == b\"x\" * 4000\n assert response.headers[\"Content-Encoding\"] == \"gzip\"\n assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n\n\ndef test_gzip_custom_exclude_content_types(test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/zip\")]})\n await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n\n middleware = GZipMiddleware(app, exclude_content_types=(\"application/zip\",))\n\n client = test_client_factory(middleware)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.content == b\"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert \"Vary\" not in response.headers\n\n\ndef test_gzip_cleared_exclude_content_types(test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"text/event-stream\")]})\n await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n\n middleware = GZipMiddleware(app, exclude_content_types=())\n\n client = test_client_factory(middleware)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.content == b\"x\" * 4000\n assert response.headers[\"Content-Encoding\"] == \"gzip\"\n assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n\n\ndef test_gzip_exclude_content_types_for_identity_client(test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/zip\")]})\n await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n\n middleware = GZipMiddleware(app, exclude_content_types=(\"application/zip\",))\n\n client = test_client_factory(middleware)\n response = client.get(\"/\", headers={\"accept-encoding\": \"identity\"})\n assert response.status_code == 200\n assert response.content == b\"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert \"Vary\" not in response.headers\n\n\n@pytest.mark.parametrize(\n (\"exclude_content_types\", \"content_type\"),\n [\n pytest.param((\"text/event-stream\",), b\"Text/Event-Stream; charset=utf-8\", id=\"header-is-normalized\"),\n pytest.param((\"Application/ZIP; charset=utf-8\",), b\"application/zip\", id=\"configured-value-is-normalized\"),\n pytest.param((\"image/*\",), b\"image/png\", id=\"wildcard\"),\n ],\n)\ndef test_gzip_exclude_content_types_matching(\n exclude_content_types: tuple[str, ...], content_type: bytes, test_client_factory: TestClientFactory\n) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", content_type)]})\n await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n\n middleware = GZipMiddleware(app, exclude_content_types=exclude_content_types)\n\n client = test_client_factory(middleware)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.content == b\"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert \"Vary\" not in response.headers\n\n\ndef test_gzip_responder_normalizes_content_types(test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/zip\")]})\n await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n\n responder = GZipResponder(app, 500, exclude_content_types=(\"Application/ZIP; charset=utf-8\",))\n\n client = test_client_factory(responder)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.content == b\"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n"}], "tests_B2": [{"path": "tests/middleware/test_gzip.py", "content": "from __future__ import annotations\n\nimport hashlib\nfrom pathlib import Path\n\nimport pytest\n\nfrom starlette.applications import Starlette\nfrom starlette.middleware import Middleware\nfrom starlette.middleware.gzip import GZipMiddleware, GZipResponder\nfrom starlette.requests import Request\nfrom starlette.responses import ContentStream, FileResponse, PlainTextResponse, StreamingResponse\nfrom starlette.routing import Route\nfrom starlette.types import Message, Receive, Scope, Send\nfrom tests.types import TestClientFactory\n\n\ndef test_gzip_responses(test_client_factory: TestClientFactory) -> None:\n def homepage(request: Request) -> PlainTextResponse:\n return PlainTextResponse(\"x\" * 4000, status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert response.headers[\"Content-Encoding\"] == \"gzip\"\n assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n assert int(response.headers[\"Content-Length\"]) < 4000\n\n\ndef test_gzip_not_in_accept_encoding(test_client_factory: TestClientFactory) -> None:\n def homepage(request: Request) -> PlainTextResponse:\n return PlainTextResponse(\"x\" * 4000, status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"identity\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n assert int(response.headers[\"Content-Length\"]) == 4000\n\n\ndef test_gzip_ignored_for_small_responses(\n test_client_factory: TestClientFactory,\n) -> None:\n def homepage(request: Request) -> PlainTextResponse:\n return PlainTextResponse(\"OK\", status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.text == \"OK\"\n assert \"Content-Encoding\" not in response.headers\n assert \"Vary\" not in response.headers\n assert int(response.headers[\"Content-Length\"]) == 2\n\n\ndef test_gzip_streaming_response(test_client_factory: TestClientFactory) -> None:\n def homepage(request: Request) -> StreamingResponse:\n async def generator(bytes: bytes, count: int) -> ContentStream:\n for index in range(count):\n yield bytes\n\n streaming = generator(bytes=b\"x\" * 400, count=10)\n return StreamingResponse(streaming, status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert response.headers[\"Content-Encoding\"] == \"gzip\"\n assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n assert \"Content-Length\" not in response.headers\n\n\ndef test_gzip_compression_in_thread(test_client_factory: TestClientFactory) -> None:\n payload = \"x\" * (128 * 1024)\n\n def homepage(request: Request) -> PlainTextResponse:\n return PlainTextResponse(payload, status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n # Ensure the response body takes the worker-thread compression path.\n middleware=[Middleware(GZipMiddleware, thread_minimum_size=len(payload))],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.text == payload\n assert response.headers[\"Content-Encoding\"] == \"gzip\"\n assert int(response.headers[\"Content-Length\"]) < len(payload)\n\n\ndef test_gzip_streaming_compression_in_thread(test_client_factory: TestClientFactory) -> None:\n chunk = hashlib.shake_256(b\"starlette-gzip-stream\").digest(256 * 1024)\n\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/json\")]})\n await send({\"type\": \"http.response.body\", \"body\": chunk, \"more_body\": True})\n await send({\"type\": \"http.response.body\", \"body\": b\"tail\"})\n\n # Ensure the streamed chunk takes the worker-thread compression path.\n middleware = GZipMiddleware(app, thread_minimum_size=len(chunk))\n\n client = test_client_factory(middleware)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.content == chunk + b\"tail\"\n assert response.headers[\"Content-Encoding\"] == \"gzip\"\n\n\ndef test_gzip_streaming_response_identity(test_client_factory: TestClientFactory) -> None:\n def homepage(request: Request) -> StreamingResponse:\n async def generator(bytes: bytes, count: int) -> ContentStream:\n for index in range(count):\n yield bytes\n\n streaming = generator(bytes=b\"x\" * 400, count=10)\n return StreamingResponse(streaming, status_code=200)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"identity\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n assert \"Content-Length\" not in response.headers\n\n\ndef test_gzip_ignored_for_responses_with_encoding_set(\n test_client_factory: TestClientFactory,\n) -> None:\n def homepage(request: Request) -> StreamingResponse:\n async def generator(bytes: bytes, count: int) -> ContentStream:\n for index in range(count):\n yield bytes\n\n streaming = generator(bytes=b\"x\" * 400, count=10)\n return StreamingResponse(streaming, status_code=200, headers={\"Content-Encoding\": \"text\"})\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip, text\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert response.headers[\"Content-Encoding\"] == \"text\"\n assert \"Vary\" not in response.headers\n assert \"Content-Length\" not in response.headers\n\n\ndef test_gzip_ignored_on_server_sent_events(test_client_factory: TestClientFactory) -> None:\n def homepage(request: Request) -> StreamingResponse:\n async def generator(bytes: bytes, count: int) -> ContentStream:\n for _ in range(count):\n yield bytes\n\n streaming = generator(bytes=b\"x\" * 400, count=10)\n return StreamingResponse(streaming, status_code=200, media_type=\"text/event-stream\")\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.text == \"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert \"Content-Length\" not in response.headers\n\n\n@pytest.mark.anyio\nasync def test_gzip_ignored_for_pathsend_responses(tmpdir: Path) -> None:\n path = tmpdir / \"example.txt\"\n with path.open(\"w\") as file:\n file.write(\"<file content>\")\n\n events: list[Message] = []\n\n async def endpoint_with_pathsend(request: Request) -> FileResponse:\n _ = await request.body()\n return FileResponse(path)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=endpoint_with_pathsend)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n scope = {\n \"type\": \"http\",\n \"version\": \"3\",\n \"method\": \"GET\",\n \"path\": \"/\",\n \"headers\": [(b\"accept-encoding\", b\"gzip, text\")],\n \"extensions\": {\"http.response.pathsend\": {}},\n }\n\n async def receive() -> Message:\n return {\"type\": \"http.request\", \"body\": b\"\", \"more_body\": False}\n\n async def send(message: Message) -> None:\n events.append(message)\n\n await app(scope, receive, send)\n\n assert len(events) == 2\n assert events[0][\"type\"] == \"http.response.start\"\n assert events[1][\"type\"] == \"http.response.pathsend\"\n\n\ndef test_gzip_ignored_on_range_responses(tmp_path: Path, test_client_factory: TestClientFactory) -> None:\n path = tmp_path / \"example.txt\"\n path.write_text(\"x\" * 4000)\n\n def homepage(request: Request) -> FileResponse:\n return FileResponse(path)\n\n app = Starlette(\n routes=[Route(\"/\", endpoint=homepage)],\n middleware=[Middleware(GZipMiddleware)],\n )\n\n client = test_client_factory(app)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\", \"range\": \"bytes=0-1999\"})\n assert response.status_code == 206\n assert response.content == b\"x\" * 2000\n assert \"Content-Encoding\" not in response.headers\n assert int(response.headers[\"Content-Length\"]) == 2000\n\n\ndef test_gzip_custom_exclude_content_types(test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/zip\")]})\n await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n\n middleware = GZipMiddleware(app, exclude_content_types=(\"application/zip\",))\n\n client = test_client_factory(middleware)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.content == b\"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert \"Vary\" not in response.headers\n\n\ndef test_gzip_cleared_exclude_content_types(test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"text/event-stream\")]})\n await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n\n middleware = GZipMiddleware(app, exclude_content_types=())\n\n client = test_client_factory(middleware)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.content == b\"x\" * 4000\n assert response.headers[\"Content-Encoding\"] == \"gzip\"\n assert response.headers[\"Vary\"] == \"Accept-Encoding\"\n\n\ndef test_gzip_exclude_content_types_for_identity_client(test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/zip\")]})\n await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n\n middleware = GZipMiddleware(app, exclude_content_types=(\"application/zip\",))\n\n client = test_client_factory(middleware)\n response = client.get(\"/\", headers={\"accept-encoding\": \"identity\"})\n assert response.status_code == 200\n assert response.content == b\"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert \"Vary\" not in response.headers\n\n\n@pytest.mark.parametrize(\n (\"exclude_content_types\", \"content_type\"),\n [\n pytest.param((\"text/event-stream\",), b\"Text/Event-Stream; charset=utf-8\", id=\"header-is-normalized\"),\n pytest.param((\"Application/ZIP; charset=utf-8\",), b\"application/zip\", id=\"configured-value-is-normalized\"),\n pytest.param((\"image/*\",), b\"image/png\", id=\"wildcard\"),\n ],\n)\ndef test_gzip_exclude_content_types_matching(\n exclude_content_types: tuple[str, ...], content_type: bytes, test_client_factory: TestClientFactory\n) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", content_type)]})\n await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n\n middleware = GZipMiddleware(app, exclude_content_types=exclude_content_types)\n\n client = test_client_factory(middleware)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.content == b\"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n assert \"Vary\" not in response.headers\n\n\ndef test_gzip_responder_normalizes_content_types(test_client_factory: TestClientFactory) -> None:\n async def app(scope: Scope, receive: Receive, send: Send) -> None:\n await send({\"type\": \"http.response.start\", \"status\": 200, \"headers\": [(b\"content-type\", b\"application/zip\")]})\n await send({\"type\": \"http.response.body\", \"body\": b\"x\" * 4000})\n\n responder = GZipResponder(app, 500, exclude_content_types=(\"Application/ZIP; charset=utf-8\",))\n\n client = test_client_factory(responder)\n response = client.get(\"/\", headers={\"accept-encoding\": \"gzip\"})\n assert response.status_code == 200\n assert response.content == b\"x\" * 4000\n assert \"Content-Encoding\" not in response.headers\n"}], "fail_to_pass_A": ["tests/middleware/test_gzip.py::test_gzip_cleared_exclude_content_types[asyncio]", "tests/middleware/test_gzip.py::test_gzip_cleared_exclude_content_types[trio]", "tests/middleware/test_gzip.py::test_gzip_custom_exclude_content_types[asyncio]", "tests/middleware/test_gzip.py::test_gzip_custom_exclude_content_types[trio]", "tests/middleware/test_gzip.py::test_gzip_exclude_content_types_for_identity_client[asyncio]", "tests/middleware/test_gzip.py::test_gzip_exclude_content_types_for_identity_client[trio]", "tests/middleware/test_gzip.py::test_gzip_exclude_content_types_matching[asyncio-configured-value-is-normalized]", "tests/middleware/test_gzip.py::test_gzip_exclude_content_types_matching[asyncio-header-is-normalized]", "tests/middleware/test_gzip.py::test_gzip_exclude_content_types_matching[asyncio-wildcard]", "tests/middleware/test_gzip.py::test_gzip_exclude_content_types_matching[trio-configured-value-is-normalized]", "tests/middleware/test_gzip.py::test_gzip_exclude_content_types_matching[trio-header-is-normalized]", "tests/middleware/test_gzip.py::test_gzip_exclude_content_types_matching[trio-wildcard]", "tests/middleware/test_gzip.py::test_gzip_responder_normalizes_content_types[asyncio]", "tests/middleware/test_gzip.py::test_gzip_responder_normalizes_content_types[trio]"], "fail_to_pass_B1": ["tests/middleware/test_gzip.py::test_gzip_default_exclude_content_types[asyncio-application/zip]", "tests/middleware/test_gzip.py::test_gzip_default_exclude_content_types[asyncio-audio/mpeg]", "tests/middleware/test_gzip.py::test_gzip_default_exclude_content_types[asyncio-font/woff2]", "tests/middleware/test_gzip.py::test_gzip_default_exclude_content_types[asyncio-image/png]", "tests/middleware/test_gzip.py::test_gzip_default_exclude_content_types[asyncio-video/mp4]", "tests/middleware/test_gzip.py::test_gzip_default_exclude_content_types[trio-application/zip]", "tests/middleware/test_gzip.py::test_gzip_default_exclude_content_types[trio-audio/mpeg]", "tests/middleware/test_gzip.py::test_gzip_default_exclude_content_types[trio-font/woff2]", "tests/middleware/test_gzip.py::test_gzip_default_exclude_content_types[trio-image/png]", "tests/middleware/test_gzip.py::test_gzip_default_exclude_content_types[trio-video/mp4]"], "fail_to_pass_B2": ["tests/middleware/test_gzip.py::test_gzip_ignored_on_range_responses[asyncio]", "tests/middleware/test_gzip.py::test_gzip_ignored_on_range_responses[trio]"], "pass_to_pass": ["tests/middleware/test_base.py::test_app_middleware_argument[asyncio]", "tests/middleware/test_base.py::test_app_middleware_argument[trio]", "tests/middleware/test_base.py::test_app_receives_http_disconnect_after_sending_if_discarded[asyncio]", "tests/middleware/test_base.py::test_app_receives_http_disconnect_after_sending_if_discarded[trio]", "tests/middleware/test_base.py::test_app_receives_http_disconnect_while_sending_if_discarded[asyncio]", "tests/middleware/test_base.py::test_app_receives_http_disconnect_while_sending_if_discarded[trio]", "tests/middleware/test_base.py::test_asgi_pathsend_events[asyncio]", "tests/middleware/test_base.py::test_asgi_pathsend_events[trio]", "tests/middleware/test_base.py::test_contextvars[asyncio-CustomMiddlewareWithoutBaseHTTPMiddleware]", "tests/middleware/test_base.py::test_contextvars[trio-CustomMiddlewareWithoutBaseHTTPMiddleware]", "tests/middleware/test_base.py::test_custom_middleware[asyncio]", "tests/middleware/test_base.py::test_custom_middleware[trio]", "tests/middleware/test_base.py::test_do_not_block_on_background_tasks[asyncio]", "tests/middleware/test_base.py::test_do_not_block_on_background_tasks[trio]", "tests/middleware/test_base.py::test_downstream_middleware_modifies_receive[asyncio]", "tests/middleware/test_base.py::test_downstream_middleware_modifies_receive[trio]", "tests/middleware/test_base.py::test_error_context_propagation[asyncio]", "tests/middleware/test_base.py::test_error_context_propagation[trio]", "tests/middleware/test_base.py::test_exception_can_be_caught[asyncio]", "tests/middleware/test_base.py::test_exception_can_be_caught[trio]", "tests/middleware/test_base.py::test_fully_evaluated_response[asyncio]", "tests/middleware/test_base.py::test_fully_evaluated_response[trio]", "tests/middleware/test_base.py::test_multiple_middlewares_stacked_client_disconnected[asyncio]", "tests/middleware/test_base.py::test_multiple_middlewares_stacked_client_disconnected[trio]", "tests/middleware/test_base.py::test_poll_for_disconnect_repeated[asyncio-False]", "tests/middleware/test_base.py::test_poll_for_disconnect_repeated[asyncio-True]", "tests/middleware/test_base.py::test_poll_for_disconnect_repeated[trio-False]", "tests/middleware/test_base.py::test_poll_for_disconnect_repeated[trio-True]", "tests/middleware/test_base.py::test_pr_1519_comment_1236166180_example", "tests/middleware/test_base.py::test_read_request_body_in_app_after_middleware_calls_body[asyncio]", "tests/middleware/test_base.py::test_read_request_body_in_app_after_middleware_calls_body[trio]", "tests/middleware/test_base.py::test_read_request_body_in_app_after_middleware_calls_stream[asyncio]", "tests/middleware/test_base.py::test_read_request_body_in_app_after_middleware_calls_stream[trio]", "tests/middleware/test_base.py::test_read_request_body_in_dispatch_after_app_calls_body_with_middleware_calling_body_before_call_next[asyncio]", "tests/middleware/test_base.py::test_read_request_body_in_dispatch_after_app_calls_body_with_middleware_calling_body_before_call_next[trio]", "tests/middleware/test_base.py::test_read_request_disconnected_after_consuming_steam[asyncio]", "tests/middleware/test_base.py::test_read_request_disconnected_after_consuming_steam[trio]", "tests/middleware/test_base.py::test_read_request_disconnected_client[asyncio]", "tests/middleware/test_base.py::test_read_request_disconnected_client[trio]", "tests/middleware/test_base.py::test_read_request_stream_in_app_after_middleware_calls_body[asyncio]", "tests/middleware/test_base.py::test_read_request_stream_in_app_after_middleware_calls_body[trio]", "tests/middleware/test_base.py::test_read_request_stream_in_app_after_middleware_calls_stream[asyncio]", "tests/middleware/test_base.py::test_read_request_stream_in_app_after_middleware_calls_stream[trio]", "tests/middleware/test_base.py::test_read_request_stream_in_dispatch_after_app_calls_body[asyncio]", "tests/middleware/test_base.py::test_read_request_stream_in_dispatch_after_app_calls_body[trio]", "tests/middleware/test_base.py::test_read_request_stream_in_dispatch_after_app_calls_body_with_middleware_calling_body_before_call_next[asyncio]", "tests/middleware/test_base.py::test_read_request_stream_in_dispatch_after_app_calls_body_with_middleware_calling_body_before_call_next[trio]", "tests/middleware/test_base.py::test_read_request_stream_in_dispatch_after_app_calls_stream[asyncio]", "tests/middleware/test_base.py::test_read_request_stream_in_dispatch_after_app_calls_stream[trio]", "tests/middleware/test_base.py::test_read_request_stream_in_dispatch_wrapping_app_calls_body[asyncio]", "tests/middleware/test_base.py::test_read_request_stream_in_dispatch_wrapping_app_calls_body[trio]", "tests/middleware/test_base.py::test_run_background_tasks_even_if_client_disconnects[asyncio]", "tests/middleware/test_base.py::test_run_background_tasks_even_if_client_disconnects[trio]", "tests/middleware/test_base.py::test_run_background_tasks_raise_exceptions[asyncio]", "tests/middleware/test_base.py::test_run_background_tasks_raise_exceptions[trio]", "tests/middleware/test_base.py::test_run_context_manager_exit_even_if_client_disconnects[asyncio]", "tests/middleware/test_base.py::test_run_context_manager_exit_even_if_client_disconnects[trio]", "tests/middleware/test_base.py::test_state_data_across_multiple_middlewares[asyncio]", "tests/middleware/test_base.py::test_state_data_across_multiple_middlewares[trio]", "tests/middleware/test_cors.py::test_cors_allow_all[asyncio]", "tests/middleware/test_cors.py::test_cors_allow_all[trio]", "tests/middleware/test_cors.py::test_cors_allow_all_except_credentials[asyncio]", "tests/middleware/test_cors.py::test_cors_allow_all_except_credentials[trio]", "tests/middleware/test_cors.py::test_cors_allow_all_methods[asyncio]", "tests/middleware/test_cors.py::test_cors_allow_all_methods[trio]", "tests/middleware/test_cors.py::test_cors_allow_origin_regex[asyncio]", "tests/middleware/test_cors.py::test_cors_allow_origin_regex[trio]", "tests/middleware/test_cors.py::test_cors_allow_origin_regex_fullmatch[asyncio]", "tests/middleware/test_cors.py::test_cors_allow_origin_regex_fullmatch[trio]", "tests/middleware/test_cors.py::test_cors_allow_specific_origin[asyncio]", "tests/middleware/test_cors.py::test_cors_allow_specific_origin[trio]", "tests/middleware/test_cors.py::test_cors_allowed_origin_does_not_leak_between_requests[asyncio]", "tests/middleware/test_cors.py::test_cors_allowed_origin_does_not_leak_between_requests[trio]", "tests/middleware/test_cors.py::test_cors_disallowed_preflight[asyncio]", "tests/middleware/test_cors.py::test_cors_disallowed_preflight[trio]", "tests/middleware/test_cors.py::test_cors_preflight_allow_all_methods[asyncio]", "tests/middleware/test_cors.py::test_cors_preflight_allow_all_methods[trio]", "tests/middleware/test_cors.py::test_cors_private_network_access_allowed[asyncio]", "tests/middleware/test_cors.py::test_cors_private_network_access_allowed[trio]", "tests/middleware/test_cors.py::test_cors_private_network_access_disallowed[asyncio]", "tests/middleware/test_cors.py::test_cors_private_network_access_disallowed[trio]", "tests/middleware/test_cors.py::test_cors_vary_header_defaults_to_origin[asyncio]", "tests/middleware/test_cors.py::test_cors_vary_header_defaults_to_origin[trio]", "tests/middleware/test_cors.py::test_cors_vary_header_is_not_set_for_non_credentialed_request[asyncio]", "tests/middleware/test_cors.py::test_cors_vary_header_is_not_set_for_non_credentialed_request[trio]", "tests/middleware/test_cors.py::test_cors_vary_header_is_properly_set_for_credentialed_request[asyncio]", "tests/middleware/test_cors.py::test_cors_vary_header_is_properly_set_for_credentialed_request[trio]", "tests/middleware/test_cors.py::test_cors_vary_header_is_properly_set_when_allow_origins_is_not_wildcard[asyncio]", "tests/middleware/test_cors.py::test_cors_vary_header_is_properly_set_when_allow_origins_is_not_wildcard[trio]", "tests/middleware/test_cors.py::test_preflight_allows_request_origin_if_origins_wildcard_and_credentials_allowed[asyncio]", "tests/middleware/test_cors.py::test_preflight_allows_request_origin_if_origins_wildcard_and_credentials_allowed[trio]", "tests/middleware/test_errors.py::test_background_task[asyncio]", "tests/middleware/test_errors.py::test_background_task[trio]", "tests/middleware/test_errors.py::test_debug_after_response_sent[asyncio]", "tests/middleware/test_errors.py::test_debug_after_response_sent[trio]", "tests/middleware/test_errors.py::test_debug_html[asyncio]", "tests/middleware/test_errors.py::test_debug_html[trio]", "tests/middleware/test_errors.py::test_debug_not_http[asyncio]", "tests/middleware/test_errors.py::test_debug_not_http[trio]", "tests/middleware/test_errors.py::test_debug_text[asyncio]", "tests/middleware/test_errors.py::test_debug_text[trio]", "tests/middleware/test_errors.py::test_handler[asyncio]", "tests/middleware/test_errors.py::test_handler[trio]", "tests/middleware/test_gzip.py::test_gzip_compression_in_thread[asyncio]", "tests/middleware/test_gzip.py::test_gzip_compression_in_thread[trio]", "tests/middleware/test_gzip.py::test_gzip_ignored_for_pathsend_responses[asyncio]", "tests/middleware/test_gzip.py::test_gzip_ignored_for_pathsend_responses[trio]", "tests/middleware/test_gzip.py::test_gzip_ignored_for_responses_with_encoding_set[asyncio]", "tests/middleware/test_gzip.py::test_gzip_ignored_for_responses_with_encoding_set[trio]", "tests/middleware/test_gzip.py::test_gzip_ignored_for_small_responses[asyncio]", "tests/middleware/test_gzip.py::test_gzip_ignored_for_small_responses[trio]", "tests/middleware/test_gzip.py::test_gzip_ignored_on_server_sent_events[asyncio]", "tests/middleware/test_gzip.py::test_gzip_ignored_on_server_sent_events[trio]", "tests/middleware/test_gzip.py::test_gzip_not_in_accept_encoding[asyncio]", "tests/middleware/test_gzip.py::test_gzip_not_in_accept_encoding[trio]", "tests/middleware/test_gzip.py::test_gzip_responses[asyncio]", "tests/middleware/test_gzip.py::test_gzip_responses[trio]", "tests/middleware/test_gzip.py::test_gzip_streaming_compression_in_thread[asyncio]", "tests/middleware/test_gzip.py::test_gzip_streaming_compression_in_thread[trio]", "tests/middleware/test_gzip.py::test_gzip_streaming_response[asyncio]", "tests/middleware/test_gzip.py::test_gzip_streaming_response[trio]", "tests/middleware/test_gzip.py::test_gzip_streaming_response_identity[asyncio]", "tests/middleware/test_gzip.py::test_gzip_streaming_response_identity[trio]", "tests/middleware/test_https_redirect.py::test_https_redirect_middleware[asyncio]", "tests/middleware/test_https_redirect.py::test_https_redirect_middleware[trio]", "tests/middleware/test_middleware.py::test_middleware_iter", "tests/middleware/test_middleware.py::test_middleware_repr", "tests/middleware/test_session.py::test_domain_cookie[asyncio]", "tests/middleware/test_session.py::test_domain_cookie[trio]", "tests/middleware/test_session.py::test_invalid_session_cookie[asyncio]", "tests/middleware/test_session.py::test_invalid_session_cookie[trio]", "tests/middleware/test_session.py::test_secure_session[asyncio]", "tests/middleware/test_session.py::test_secure_session[trio]", "tests/middleware/test_session.py::test_session[asyncio]", "tests/middleware/test_session.py::test_session[trio]", "tests/middleware/test_session.py::test_session_cookie[asyncio]", "tests/middleware/test_session.py::test_session_cookie[trio]", "tests/middleware/test_session.py::test_session_cookie_subpath[asyncio]", "tests/middleware/test_session.py::test_session_cookie_subpath[trio]", "tests/middleware/test_session.py::test_session_expires[asyncio]", "tests/middleware/test_session.py::test_session_expires[trio]", "tests/middleware/test_session.py::test_session_tracks_modification", "tests/middleware/test_session.py::test_set_cookie_only_on_modification[asyncio]", "tests/middleware/test_session.py::test_set_cookie_only_on_modification[trio]", "tests/middleware/test_session.py::test_vary_cookie_on_access[asyncio]", "tests/middleware/test_session.py::test_vary_cookie_on_access[trio]", "tests/middleware/test_trusted_host.py::test_default_allowed_hosts", "tests/middleware/test_trusted_host.py::test_trusted_host_middleware[asyncio]", "tests/middleware/test_trusted_host.py::test_trusted_host_middleware[trio]", "tests/middleware/test_trusted_host.py::test_www_redirect[asyncio]", "tests/middleware/test_trusted_host.py::test_www_redirect[trio]", "tests/middleware/test_wsgi.py::test_build_environ", "tests/middleware/test_wsgi.py::test_build_environ_encoding", "tests/middleware/test_wsgi.py::test_wsgi_exc_info[asyncio]", "tests/middleware/test_wsgi.py::test_wsgi_exc_info[trio]", "tests/middleware/test_wsgi.py::test_wsgi_exception[asyncio]", "tests/middleware/test_wsgi.py::test_wsgi_exception[trio]", "tests/middleware/test_wsgi.py::test_wsgi_get[asyncio]", "tests/middleware/test_wsgi.py::test_wsgi_get[trio]", "tests/middleware/test_wsgi.py::test_wsgi_post[asyncio]", "tests/middleware/test_wsgi.py::test_wsgi_post[trio]", "tests/test__utils.py::test_async_func", "tests/test__utils.py::test_async_method", "tests/test__utils.py::test_async_mocked_async_function", "tests/test__utils.py::test_async_nested_partial", "tests/test__utils.py::test_async_object_call", "tests/test__utils.py::test_async_partial", "tests/test__utils.py::test_async_partial_object_call", "tests/test__utils.py::test_collapsing_task_group_one_exc[asyncio]", "tests/test__utils.py::test_collapsing_task_group_one_exc[trio]", "tests/test__utils.py::test_collapsing_task_group_two_exc[asyncio]", "tests/test__utils.py::test_collapsing_task_group_two_exc[trio]", "tests/test__utils.py::test_get_route_path[scope0-/foo-123/bar]", "tests/test__utils.py::test_get_route_path[scope1-/bar]", "tests/test__utils.py::test_get_route_path[scope2-]", "tests/test__utils.py::test_get_route_path[scope3-/foo/bar]", "tests/test_applications.py::test_400[asyncio]", "tests/test_applications.py::test_400[trio]", "tests/test_applications.py::test_405[asyncio]", "tests/test_applications.py::test_405[trio]", "tests/test_applications.py::test_500[asyncio]", "tests/test_applications.py::test_500[trio]", "tests/test_applications.py::test_app_add_route[asyncio]", "tests/test_applications.py::test_app_add_route[trio]", "tests/test_applications.py::test_app_add_websocket_route[asyncio]", "tests/test_applications.py::test_app_add_websocket_route[trio]", "tests/test_applications.py::test_app_async_cm_lifespan[asyncio]", "tests/test_applications.py::test_app_async_cm_lifespan[trio]", "tests/test_applications.py::test_app_async_gen_lifespan[asyncio]", "tests/test_applications.py::test_app_async_gen_lifespan[trio]", "tests/test_applications.py::test_app_debug[asyncio]", "tests/test_applications.py::test_app_debug[trio]", "tests/test_applications.py::test_app_mount[asyncio]", "tests/test_applications.py::test_app_mount[trio]", "tests/test_applications.py::test_app_sync_gen_lifespan[asyncio]", "tests/test_applications.py::test_app_sync_gen_lifespan[trio]", "tests/test_applications.py::test_async_route[asyncio]", "tests/test_applications.py::test_async_route[trio]", "tests/test_applications.py::test_class_route[asyncio]", "tests/test_applications.py::test_class_route[trio]", "tests/test_applications.py::test_func_route[asyncio]", "tests/test_applications.py::test_func_route[trio]", "tests/test_applications.py::test_lifespan_app_subclass", "tests/test_applications.py::test_middleware[asyncio]", "tests/test_applications.py::test_middleware[trio]", "tests/test_applications.py::test_middleware_args[asyncio]", "tests/test_applications.py::test_middleware_args[trio]", "tests/test_applications.py::test_middleware_factory[asyncio]", "tests/test_applications.py::test_middleware_factory[trio]", "tests/test_applications.py::test_middleware_stack_init[asyncio]", "tests/test_applications.py::test_middleware_stack_init[trio]", "tests/test_applications.py::test_mounted_route[asyncio]", "tests/test_applications.py::test_mounted_route[trio]", "tests/test_applications.py::test_mounted_route_path_params[asyncio]", "tests/test_applications.py::test_mounted_route_path_params[trio]", "tests/test_applications.py::test_request_state[asyncio]", "tests/test_applications.py::test_request_state[trio]", "tests/test_applications.py::test_routes", "tests/test_applications.py::test_subdomain_route[asyncio]", "tests/test_applications.py::test_subdomain_route[trio]", "tests/test_applications.py::test_url_path_for", "tests/test_applications.py::test_websocket_raise_custom_exception[asyncio]", "tests/test_applications.py::test_websocket_raise_custom_exception[trio]", "tests/test_applications.py::test_websocket_raise_http_exception[asyncio]", "tests/test_applications.py::test_websocket_raise_http_exception[trio]", "tests/test_applications.py::test_websocket_raise_websocket_exception[asyncio]", "tests/test_applications.py::test_websocket_raise_websocket_exception[trio]", "tests/test_applications.py::test_websocket_route[asyncio]", "tests/test_applications.py::test_websocket_route[trio]", "tests/test_applications.py::test_websocket_state[asyncio]", "tests/test_applications.py::test_websocket_state[trio]", "tests/test_authentication.py::test_authentication_redirect[asyncio]", "tests/test_authentication.py::test_authentication_redirect[trio]", "tests/test_authentication.py::test_authentication_required[asyncio]", "tests/test_authentication.py::test_authentication_required[trio]", "tests/test_authentication.py::test_custom_on_error[asyncio]", "tests/test_authentication.py::test_custom_on_error[trio]", "tests/test_authentication.py::test_invalid_decorator_usage", "tests/test_authentication.py::test_user_interface[asyncio]", "tests/test_authentication.py::test_user_interface[trio]", "tests/test_authentication.py::test_websocket_authentication_required[asyncio]", "tests/test_authentication.py::test_websocket_authentication_required[trio]", "tests/test_background.py::test_async_task[asyncio]", "tests/test_background.py::test_async_task[trio]", "tests/test_background.py::test_multi_tasks_failure_avoids_next_execution[asyncio]", "tests/test_background.py::test_multi_tasks_failure_avoids_next_execution[trio]", "tests/test_background.py::test_multiple_tasks[asyncio]", "tests/test_background.py::test_multiple_tasks[trio]", "tests/test_background.py::test_sync_task[asyncio]", "tests/test_background.py::test_sync_task[trio]", "tests/test_concurrency.py::test_accessing_context_from_threaded_sync_endpoint[asyncio]", "tests/test_concurrency.py::test_accessing_context_from_threaded_sync_endpoint[trio]", "tests/test_concurrency.py::test_iterate_in_threadpool[asyncio]", "tests/test_concurrency.py::test_iterate_in_threadpool[trio]", "tests/test_concurrency.py::test_run_until_first_complete[asyncio]", "tests/test_concurrency.py::test_run_until_first_complete[trio]", "tests/test_config.py::test_config", "tests/test_config.py::test_config_types", "tests/test_config.py::test_config_with_encoding", "tests/test_config.py::test_config_with_env_prefix", "tests/test_config.py::test_environ", "tests/test_config.py::test_missing_env_file_raises", "tests/test_convertors.py::test_datetime_convertor[asyncio]", "tests/test_convertors.py::test_datetime_convertor[trio]", "tests/test_convertors.py::test_default_float_convertor[asyncio-1-0-404]", "tests/test_convertors.py::test_default_float_convertor[asyncio-1.0-200]", "tests/test_convertors.py::test_default_float_convertor[trio-1-0-404]", "tests/test_convertors.py::test_default_float_convertor[trio-1.0-200]", "tests/test_convertors.py::test_default_uuid_convertor[asyncio-00000000-AAAA-FFFF-9999-000000000000-200]", "tests/test_convertors.py::test_default_uuid_convertor[asyncio-00000000-aaaa-ffff-9999-000000000000-200]", "tests/test_convertors.py::test_default_uuid_convertor[asyncio-00000000AAAAFFFF9999000000000000-200]", "tests/test_convertors.py::test_default_uuid_convertor[asyncio-00000000aaaaffff9999000000000000-200]", "tests/test_convertors.py::test_default_uuid_convertor[asyncio-not-a-uuid-404]", "tests/test_convertors.py::test_default_uuid_convertor[trio-00000000-AAAA-FFFF-9999-000000000000-200]", "tests/test_convertors.py::test_default_uuid_convertor[trio-00000000-aaaa-ffff-9999-000000000000-200]", "tests/test_convertors.py::test_default_uuid_convertor[trio-00000000AAAAFFFF9999000000000000-200]", "tests/test_convertors.py::test_default_uuid_convertor[trio-00000000aaaaffff9999000000000000-200]", "tests/test_convertors.py::test_default_uuid_convertor[trio-not-a-uuid-404]", "tests/test_datastructures.py::test_csv", "tests/test_datastructures.py::test_formdata", "tests/test_datastructures.py::test_headers", "tests/test_datastructures.py::test_headers_mutablecopy", "tests/test_datastructures.py::test_hidden_password", "tests/test_datastructures.py::test_multidict", "tests/test_datastructures.py::test_mutable_headers", "tests/test_datastructures.py::test_mutable_headers_from_scope", "tests/test_datastructures.py::test_mutable_headers_merge", "tests/test_datastructures.py::test_mutable_headers_merge_dict", "tests/test_datastructures.py::test_mutable_headers_merge_not_mapping", "tests/test_datastructures.py::test_mutable_headers_update", "tests/test_datastructures.py::test_mutable_headers_update_dict", "tests/test_datastructures.py::test_queryparams", "tests/test_datastructures.py::test_upload_file_file_input[asyncio]", "tests/test_datastructures.py::test_upload_file_file_input[trio]", "tests/test_datastructures.py::test_upload_file_repr[asyncio]", "tests/test_datastructures.py::test_upload_file_repr[trio]", "tests/test_datastructures.py::test_upload_file_repr_headers[asyncio]", "tests/test_datastructures.py::test_upload_file_repr_headers[trio]", "tests/test_datastructures.py::test_upload_file_without_size[asyncio]", "tests/test_datastructures.py::test_upload_file_without_size[trio]", "tests/test_datastructures.py::test_uploadfile_rolling[asyncio-rolled]", "tests/test_datastructures.py::test_uploadfile_rolling[asyncio-unrolled]", "tests/test_datastructures.py::test_uploadfile_rolling[trio-rolled]", "tests/test_datastructures.py::test_uploadfile_rolling[trio-unrolled]", "tests/test_datastructures.py::test_url", "tests/test_datastructures.py::test_url_blank_params", "tests/test_datastructures.py::test_url_from_scope", "tests/test_datastructures.py::test_url_from_scope_with_authority_in_path[host-header-absolute]", "tests/test_datastructures.py::test_url_from_scope_with_authority_in_path[host-header-at-sign]", "tests/test_datastructures.py::test_url_from_scope_with_authority_in_path[host-header-scheme-relative]", "tests/test_datastructures.py::test_url_from_scope_with_authority_in_path[host-header-userinfo]", "tests/test_datastructures.py::test_url_from_scope_with_authority_in_path[server-fallback-absolute]", "tests/test_datastructures.py::test_url_from_scope_with_authority_in_path[server-fallback-at-sign]", "tests/test_datastructures.py::test_url_from_scope_with_authority_in_path[server-fallback-scheme-relative]", "tests/test_datastructures.py::test_url_from_scope_with_authority_in_path[server-fallback-userinfo]", "tests/test_datastructures.py::test_url_from_scope_with_invalid_host[at-sign]", "tests/test_datastructures.py::test_url_from_scope_with_invalid_host[backslash]", "tests/test_datastructures.py::test_url_from_scope_with_invalid_host[hash]", "tests/test_datastructures.py::test_url_from_scope_with_invalid_host[question-mark]", "tests/test_datastructures.py::test_url_from_scope_with_invalid_host[slash]", "tests/test_datastructures.py::test_url_from_scope_with_invalid_host[space]", "tests/test_datastructures.py::test_url_query_params", "tests/test_endpoints.py::test_http_endpoint_does_not_dispatch_non_verb_method[asyncio]", "tests/test_endpoints.py::test_http_endpoint_does_not_dispatch_non_verb_method[trio]", "tests/test_endpoints.py::test_http_endpoint_route[asyncio]", "tests/test_endpoints.py::test_http_endpoint_route[trio]", "tests/test_endpoints.py::test_http_endpoint_route_method[asyncio]", "tests/test_endpoints.py::test_http_endpoint_route_method[trio]", "tests/test_endpoints.py::test_http_endpoint_route_path_params[asyncio]", "tests/test_endpoints.py::test_http_endpoint_route_path_params[trio]", "tests/test_endpoints.py::test_websocket_endpoint_on_connect[asyncio]", "tests/test_endpoints.py::test_websocket_endpoint_on_connect[trio]", "tests/test_endpoints.py::test_websocket_endpoint_on_default[asyncio]", "tests/test_endpoints.py::test_websocket_endpoint_on_default[trio]", "tests/test_endpoints.py::test_websocket_endpoint_on_disconnect[asyncio]", "tests/test_endpoints.py::test_websocket_endpoint_on_disconnect[trio]", "tests/test_endpoints.py::test_websocket_endpoint_on_receive_bytes[asyncio]", "tests/test_endpoints.py::test_websocket_endpoint_on_receive_bytes[trio]", "tests/test_endpoints.py::test_websocket_endpoint_on_receive_json[asyncio]", "tests/test_endpoints.py::test_websocket_endpoint_on_receive_json[trio]", "tests/test_endpoints.py::test_websocket_endpoint_on_receive_json_binary[asyncio]", "tests/test_endpoints.py::test_websocket_endpoint_on_receive_json_binary[trio]", "tests/test_endpoints.py::test_websocket_endpoint_on_receive_text[asyncio]", "tests/test_endpoints.py::test_websocket_endpoint_on_receive_text[trio]", "tests/test_exceptions.py::test_force_500_response[asyncio]", "tests/test_exceptions.py::test_force_500_response[trio]", "tests/test_exceptions.py::test_handled_exc_after_response[asyncio]", "tests/test_exceptions.py::test_handled_exc_after_response[trio]", "tests/test_exceptions.py::test_handlers_annotations", "tests/test_exceptions.py::test_http_exception_does_not_use_threadpool[asyncio]", "tests/test_exceptions.py::test_http_exception_does_not_use_threadpool[trio]", "tests/test_exceptions.py::test_http_repr", "tests/test_exceptions.py::test_http_str", "tests/test_exceptions.py::test_no_content[asyncio]", "tests/test_exceptions.py::test_no_content[trio]", "tests/test_exceptions.py::test_not_acceptable[asyncio]", "tests/test_exceptions.py::test_not_acceptable[trio]", "tests/test_exceptions.py::test_not_modified[asyncio]", "tests/test_exceptions.py::test_not_modified[trio]", "tests/test_exceptions.py::test_request_in_app_and_handler_is_the_same_object[asyncio]", "tests/test_exceptions.py::test_request_in_app_and_handler_is_the_same_object[trio]", "tests/test_exceptions.py::test_websocket_repr", "tests/test_exceptions.py::test_websocket_str", "tests/test_exceptions.py::test_websockets_should_raise[asyncio]", "tests/test_exceptions.py::test_websockets_should_raise[trio]", "tests/test_exceptions.py::test_with_headers[asyncio]", "tests/test_exceptions.py::test_with_headers[trio]", "tests/test_formparsers.py::test_max_fields_is_customizable_high[asyncio]", "tests/test_formparsers.py::test_max_fields_is_customizable_high[trio]", "tests/test_formparsers.py::test_max_fields_is_customizable_low_raises[asyncio-app-expectation0]", "tests/test_formparsers.py::test_max_fields_is_customizable_low_raises[asyncio-app1-expectation1]", "tests/test_formparsers.py::test_max_fields_is_customizable_low_raises[trio-app-expectation0]", "tests/test_formparsers.py::test_max_fields_is_customizable_low_raises[trio-app1-expectation1]", "tests/test_formparsers.py::test_max_files_is_customizable_low_raises[asyncio-app-expectation0]", "tests/test_formparsers.py::test_max_files_is_customizable_low_raises[asyncio-app1-expectation1]", "tests/test_formparsers.py::test_max_files_is_customizable_low_raises[trio-app-expectation0]", "tests/test_formparsers.py::test_max_files_is_customizable_low_raises[trio-app1-expectation1]", "tests/test_formparsers.py::test_max_part_size_exceeds_custom_limit[asyncio-app-expectation0]", "tests/test_formparsers.py::test_max_part_size_exceeds_custom_limit[asyncio-app1-expectation1]", "tests/test_formparsers.py::test_max_part_size_exceeds_custom_limit[trio-app-expectation0]", "tests/test_formparsers.py::test_max_part_size_exceeds_custom_limit[trio-app1-expectation1]", "tests/test_formparsers.py::test_max_part_size_exceeds_limit[asyncio-app-expectation0]", "tests/test_formparsers.py::test_max_part_size_exceeds_limit[asyncio-app1-expectation1]", "tests/test_formparsers.py::test_max_part_size_exceeds_limit[trio-app-expectation0]", "tests/test_formparsers.py::test_max_part_size_exceeds_limit[trio-app1-expectation1]", "tests/test_formparsers.py::test_missing_boundary_parameter[asyncio-app-expectation0]", "tests/test_formparsers.py::test_missing_boundary_parameter[asyncio-app1-expectation1]", "tests/test_formparsers.py::test_missing_boundary_parameter[trio-app-expectation0]", "tests/test_formparsers.py::test_missing_boundary_parameter[trio-app1-expectation1]", "tests/test_formparsers.py::test_missing_name_parameter_on_content_disposition[asyncio-app-expectation0]", "tests/test_formparsers.py::test_missing_name_parameter_on_content_disposition[asyncio-app1-expectation1]", "tests/test_formparsers.py::test_missing_name_parameter_on_content_disposition[trio-app-expectation0]", "tests/test_formparsers.py::test_missing_name_parameter_on_content_disposition[trio-app1-expectation1]", "tests/test_formparsers.py::test_multi_items[asyncio]", "tests/test_formparsers.py::test_multi_items[trio]", "tests/test_formparsers.py::test_multipart_closes_tempfile_on_oserror[asyncio]", "tests/test_formparsers.py::test_multipart_closes_tempfile_on_oserror[trio]", "tests/test_formparsers.py::test_multipart_multi_field_app_reads_body[asyncio]", "tests/test_formparsers.py::test_multipart_multi_field_app_reads_body[trio]", "tests/test_formparsers.py::test_multipart_request_data[asyncio]", "tests/test_formparsers.py::test_multipart_request_data[trio]", "tests/test_formparsers.py::test_multipart_request_files[asyncio]", "tests/test_formparsers.py::test_multipart_request_files[trio]", "tests/test_formparsers.py::test_multipart_request_files_with_content_type[asyncio]", "tests/test_formparsers.py::test_multipart_request_files_with_content_type[trio]", "tests/test_formparsers.py::test_multipart_request_large_file_rollover_in_background_thread[asyncio]", "tests/test_formparsers.py::test_multipart_request_large_file_rollover_in_background_thread[trio]", "tests/test_formparsers.py::test_multipart_request_mixed_files_and_data[asyncio]", "tests/test_formparsers.py::test_multipart_request_mixed_files_and_data[trio]", "tests/test_formparsers.py::test_multipart_request_multiple_files[asyncio]", "tests/test_formparsers.py::test_multipart_request_multiple_files[trio]", "tests/test_formparsers.py::test_multipart_request_multiple_files_with_headers[asyncio]", "tests/test_formparsers.py::test_multipart_request_multiple_files_with_headers[trio]", "tests/test_formparsers.py::test_multipart_request_with_charset_for_filename[asyncio]", "tests/test_formparsers.py::test_multipart_request_with_charset_for_filename[trio]", "tests/test_formparsers.py::test_multipart_request_with_encoded_value[asyncio]", "tests/test_formparsers.py::test_multipart_request_with_encoded_value[trio]", "tests/test_formparsers.py::test_multipart_request_without_charset_for_filename[asyncio]", "tests/test_formparsers.py::test_multipart_request_without_charset_for_filename[trio]", "tests/test_formparsers.py::test_no_request_data[asyncio]", "tests/test_formparsers.py::test_no_request_data[trio]", "tests/test_formparsers.py::test_too_many_fields_raise[asyncio-app-expectation0]", "tests/test_formparsers.py::test_too_many_fields_raise[asyncio-app1-expectation1]", "tests/test_formparsers.py::test_too_many_fields_raise[trio-app-expectation0]", "tests/test_formparsers.py::test_too_many_fields_raise[trio-app1-expectation1]", "tests/test_formparsers.py::test_too_many_files_and_fields_raise[asyncio-app-expectation0]", "tests/test_formparsers.py::test_too_many_files_and_fields_raise[asyncio-app1-expectation1]", "tests/test_formparsers.py::test_too_many_files_and_fields_raise[trio-app-expectation0]", "tests/test_formparsers.py::test_too_many_files_and_fields_raise[trio-app1-expectation1]", "tests/test_formparsers.py::test_too_many_files_raise[asyncio-app-expectation0]", "tests/test_formparsers.py::test_too_many_files_raise[asyncio-app1-expectation1]", "tests/test_formparsers.py::test_too_many_files_raise[trio-app-expectation0]", "tests/test_formparsers.py::test_too_many_files_raise[trio-app1-expectation1]", "tests/test_formparsers.py::test_too_many_files_single_field_raise[asyncio-app-expectation0]", "tests/test_formparsers.py::test_too_many_files_single_field_raise[asyncio-app1-expectation1]", "tests/test_formparsers.py::test_too_many_files_single_field_raise[trio-app-expectation0]", "tests/test_formparsers.py::test_too_many_files_single_field_raise[trio-app1-expectation1]", "tests/test_formparsers.py::test_urlencoded_field_exceeds_max_part_size_raise[asyncio-app-expectation0]", "tests/test_formparsers.py::test_urlencoded_field_exceeds_max_part_size_raise[asyncio-app1-expectation1]", "tests/test_formparsers.py::test_urlencoded_field_exceeds_max_part_size_raise[trio-app-expectation0]", "tests/test_formparsers.py::test_urlencoded_field_exceeds_max_part_size_raise[trio-app1-expectation1]", "tests/test_formparsers.py::test_urlencoded_field_name_exceeds_max_part_size_raise[asyncio-app-expectation0]", "tests/test_formparsers.py::test_urlencoded_field_name_exceeds_max_part_size_raise[asyncio-app1-expectation1]", "tests/test_formparsers.py::test_urlencoded_field_name_exceeds_max_part_size_raise[trio-app-expectation0]", "tests/test_formparsers.py::test_urlencoded_field_name_exceeds_max_part_size_raise[trio-app1-expectation1]", "tests/test_formparsers.py::test_urlencoded_limits_stop_parsing_within_a_single_chunk[asyncio]", "tests/test_formparsers.py::test_urlencoded_limits_stop_parsing_within_a_single_chunk[trio]", "tests/test_formparsers.py::test_urlencoded_max_fields_is_customizable[asyncio-app-expectation0]", "tests/test_formparsers.py::test_urlencoded_max_fields_is_customizable[asyncio-app1-expectation1]", "tests/test_formparsers.py::test_urlencoded_max_fields_is_customizable[trio-app-expectation0]", "tests/test_formparsers.py::test_urlencoded_max_fields_is_customizable[trio-app1-expectation1]", "tests/test_formparsers.py::test_urlencoded_max_part_size_is_customizable[asyncio-app-expectation0]", "tests/test_formparsers.py::test_urlencoded_max_part_size_is_customizable[asyncio-app1-expectation1]", "tests/test_formparsers.py::test_urlencoded_max_part_size_is_customizable[trio-app-expectation0]", "tests/test_formparsers.py::test_urlencoded_max_part_size_is_customizable[trio-app1-expectation1]", "tests/test_formparsers.py::test_urlencoded_multi_field_app_reads_body[asyncio]", "tests/test_formparsers.py::test_urlencoded_multi_field_app_reads_body[trio]", "tests/test_formparsers.py::test_urlencoded_percent_encoding[asyncio]", "tests/test_formparsers.py::test_urlencoded_percent_encoding[trio]", "tests/test_formparsers.py::test_urlencoded_percent_encoding_keys[asyncio]", "tests/test_formparsers.py::test_urlencoded_percent_encoding_keys[trio]", "tests/test_formparsers.py::test_urlencoded_request_data[asyncio]", "tests/test_formparsers.py::test_urlencoded_request_data[trio]", "tests/test_formparsers.py::test_urlencoded_too_many_fields_raise[asyncio-app-expectation0]", "tests/test_formparsers.py::test_urlencoded_too_many_fields_raise[asyncio-app1-expectation1]", "tests/test_formparsers.py::test_urlencoded_too_many_fields_raise[trio-app-expectation0]", "tests/test_formparsers.py::test_urlencoded_too_many_fields_raise[trio-app1-expectation1]", "tests/test_formparsers.py::test_user_safe_decode_helper", "tests/test_formparsers.py::test_user_safe_decode_ignores_wrong_charset", "tests/test_requests.py::test_chunked_encoding[asyncio]", "tests/test_requests.py::test_chunked_encoding[trio]", "tests/test_requests.py::test_cookie_lenient_parsing[asyncio]", "tests/test_requests.py::test_cookie_lenient_parsing[trio]", "tests/test_requests.py::test_cookies_edge_cases[asyncio-a=b; Domain=example.com-expected5]", "tests/test_requests.py::test_cookies_edge_cases[asyncio-a=b; c=[; d=r; f=h-expected4]", "tests/test_requests.py::test_cookies_edge_cases[asyncio-a=b; h=i; a=c-expected6]", "tests/test_requests.py::test_cookies_edge_cases[asyncio-chips=ahoy; vienna=finger-expected0]", "tests/test_requests.py::test_cookies_edge_cases[asyncio-keebler=\"E=mc2; L=\\\\\"Loves\\\\\"; fudge=\\\\012;\"-expected1]", "tests/test_requests.py::test_cookies_edge_cases[asyncio-keebler=E=mc2-expected2]", "tests/test_requests.py::test_cookies_edge_cases[asyncio-key:term=value:term-expected3]", "tests/test_requests.py::test_cookies_edge_cases[trio-a=b; Domain=example.com-expected5]", "tests/test_requests.py::test_cookies_edge_cases[trio-a=b; c=[; d=r; f=h-expected4]", "tests/test_requests.py::test_cookies_edge_cases[trio-a=b; h=i; a=c-expected6]", "tests/test_requests.py::test_cookies_edge_cases[trio-chips=ahoy; vienna=finger-expected0]", "tests/test_requests.py::test_cookies_edge_cases[trio-keebler=\"E=mc2; L=\\\\\"Loves\\\\\"; fudge=\\\\012;\"-expected1]", "tests/test_requests.py::test_cookies_edge_cases[trio-keebler=E=mc2-expected2]", "tests/test_requests.py::test_cookies_edge_cases[trio-key:term=value:term-expected3]", "tests/test_requests.py::test_cookies_invalid[asyncio- = b ; ; = ; c = ; -expected4]", "tests/test_requests.py::test_cookies_invalid[asyncio-a b,c<>@:/[]?{}=d \" =e,f g-expected3]", "tests/test_requests.py::test_cookies_invalid[asyncio-a b c=d e = f; gh=i-expected2]", "tests/test_requests.py::test_cookies_invalid[asyncio-a=b; \"; c=d-expected1]", "tests/test_requests.py::test_cookies_invalid[asyncio-abc=def; unnamed; django_language=en-expected0]", "tests/test_requests.py::test_cookies_invalid[trio- = b ; ; = ; c = ; -expected4]", "tests/test_requests.py::test_cookies_invalid[trio-a b,c<>@:/[]?{}=d \" =e,f g-expected3]", "tests/test_requests.py::test_cookies_invalid[trio-a b c=d e = f; gh=i-expected2]", "tests/test_requests.py::test_cookies_invalid[trio-a=b; \"; c=d-expected1]", "tests/test_requests.py::test_cookies_invalid[trio-abc=def; unnamed; django_language=en-expected0]", "tests/test_requests.py::test_multiple_cookie_headers[asyncio]", "tests/test_requests.py::test_multiple_cookie_headers[trio]", "tests/test_requests.py::test_request_body[asyncio]", "tests/test_requests.py::test_request_body[trio]", "tests/test_requests.py::test_request_body_then_stream[asyncio]", "tests/test_requests.py::test_request_body_then_stream[trio]", "tests/test_requests.py::test_request_client[scope0-expected_client0]", "tests/test_requests.py::test_request_client[scope1-None]", "tests/test_requests.py::test_request_client[scope2-None]", "tests/test_requests.py::test_request_cookies[asyncio]", "tests/test_requests.py::test_request_cookies[trio]", "tests/test_requests.py::test_request_disconnect[asyncio]", "tests/test_requests.py::test_request_disconnect[trio]", "tests/test_requests.py::test_request_form_context_manager[asyncio]", "tests/test_requests.py::test_request_form_context_manager[trio]", "tests/test_requests.py::test_request_form_urlencoded[asyncio]", "tests/test_requests.py::test_request_form_urlencoded[trio]", "tests/test_requests.py::test_request_headers[asyncio]", "tests/test_requests.py::test_request_headers[trio]", "tests/test_requests.py::test_request_is_disconnected[asyncio]", "tests/test_requests.py::test_request_is_disconnected[trio]", "tests/test_requests.py::test_request_json[asyncio]", "tests/test_requests.py::test_request_json[trio]", "tests/test_requests.py::test_request_query_params[asyncio]", "tests/test_requests.py::test_request_query_params[trio]", "tests/test_requests.py::test_request_raw_path[asyncio]", "tests/test_requests.py::test_request_raw_path[trio]", "tests/test_requests.py::test_request_rcv[asyncio-messages0]", "tests/test_requests.py::test_request_rcv[asyncio-messages1]", "tests/test_requests.py::test_request_rcv[asyncio-messages2]", "tests/test_requests.py::test_request_rcv[asyncio-messages3]", "tests/test_requests.py::test_request_rcv[trio-messages0]", "tests/test_requests.py::test_request_rcv[trio-messages1]", "tests/test_requests.py::test_request_rcv[trio-messages2]", "tests/test_requests.py::test_request_rcv[trio-messages3]", "tests/test_requests.py::test_request_scope_interface", "tests/test_requests.py::test_request_send_push_promise[asyncio]", "tests/test_requests.py::test_request_send_push_promise[trio]", "tests/test_requests.py::test_request_send_push_promise_without_push_extension[asyncio]", "tests/test_requests.py::test_request_send_push_promise_without_push_extension[trio]", "tests/test_requests.py::test_request_send_push_promise_without_setting_send[asyncio]", "tests/test_requests.py::test_request_send_push_promise_without_setting_send[trio]", "tests/test_requests.py::test_request_state[asyncio]", "tests/test_requests.py::test_request_state[trio]", "tests/test_requests.py::test_request_state_object", "tests/test_requests.py::test_request_stream[asyncio]", "tests/test_requests.py::test_request_stream[trio]", "tests/test_requests.py::test_request_stream_called_twice[asyncio]", "tests/test_requests.py::test_request_stream_called_twice[trio]", "tests/test_requests.py::test_request_stream_then_body[asyncio]", "tests/test_requests.py::test_request_stream_then_body[trio]", "tests/test_requests.py::test_request_url[asyncio]", "tests/test_requests.py::test_request_url[trio]", "tests/test_requests.py::test_request_url_outside_starlette_context[asyncio]", "tests/test_requests.py::test_request_url_outside_starlette_context[trio]", "tests/test_requests.py::test_request_url_starlette_context[asyncio]", "tests/test_requests.py::test_request_url_starlette_context[trio]", "tests/test_requests.py::test_request_without_setting_receive[asyncio]", "tests/test_requests.py::test_request_without_setting_receive[trio]", "tests/test_responses.py::test_bytes_response[asyncio]", "tests/test_responses.py::test_bytes_response[trio]", "tests/test_responses.py::test_delete_cookie[asyncio]", "tests/test_responses.py::test_delete_cookie[trio]", "tests/test_responses.py::test_empty_204_response[asyncio]", "tests/test_responses.py::test_empty_204_response[trio]", "tests/test_responses.py::test_empty_response[asyncio]", "tests/test_responses.py::test_empty_response[trio]", "tests/test_responses.py::test_expires_on_set_cookie[asyncio-datetime]", "tests/test_responses.py::test_expires_on_set_cookie[asyncio-int]", "tests/test_responses.py::test_expires_on_set_cookie[asyncio-str]", "tests/test_responses.py::test_expires_on_set_cookie[trio-datetime]", "tests/test_responses.py::test_expires_on_set_cookie[trio-int]", "tests/test_responses.py::test_expires_on_set_cookie[trio-str]", "tests/test_responses.py::test_file_response[asyncio]", "tests/test_responses.py::test_file_response[trio]", "tests/test_responses.py::test_file_response_default_media_type[asyncio]", "tests/test_responses.py::test_file_response_default_media_type[trio]", "tests/test_responses.py::test_file_response_head[asyncio]", "tests/test_responses.py::test_file_response_head[trio]", "tests/test_responses.py::test_file_response_insert_ranges[asyncio]", "tests/test_responses.py::test_file_response_insert_ranges[trio]", "tests/test_responses.py::test_file_response_known_size[asyncio]", "tests/test_responses.py::test_file_response_known_size[trio]", "tests/test_responses.py::test_file_response_merge_ranges[asyncio]", "tests/test_responses.py::test_file_response_merge_ranges[trio]", "tests/test_responses.py::test_file_response_multi_small_chunk_size[asyncio]", "tests/test_responses.py::test_file_response_multi_small_chunk_size[trio]", "tests/test_responses.py::test_file_response_multiple_calls[asyncio]", "tests/test_responses.py::test_file_response_multiple_calls[trio]", "tests/test_responses.py::test_file_response_on_head_method[asyncio]", "tests/test_responses.py::test_file_response_on_head_method[trio]", "tests/test_responses.py::test_file_response_only_support_bytes_range[asyncio]", "tests/test_responses.py::test_file_response_only_support_bytes_range[trio]", "tests/test_responses.py::test_file_response_range[asyncio]", "tests/test_responses.py::test_file_response_range[trio]", "tests/test_responses.py::test_file_response_range_416[asyncio]", "tests/test_responses.py::test_file_response_range_416[trio]", "tests/test_responses.py::test_file_response_range_empty_start_and_end[asyncio]", "tests/test_responses.py::test_file_response_range_empty_start_and_end[trio]", "tests/test_responses.py::test_file_response_range_head[asyncio]", "tests/test_responses.py::test_file_response_range_head[trio]", "tests/test_responses.py::test_file_response_range_head_max[asyncio]", "tests/test_responses.py::test_file_response_range_head_max[trio]", "tests/test_responses.py::test_file_response_range_ignore_non_numeric[asyncio]", "tests/test_responses.py::test_file_response_range_ignore_non_numeric[trio]", "tests/test_responses.py::test_file_response_range_invalid[asyncio]", "tests/test_responses.py::test_file_response_range_invalid[trio]", "tests/test_responses.py::test_file_response_range_multi[asyncio]", "tests/test_responses.py::test_file_response_range_multi[trio]", "tests/test_responses.py::test_file_response_range_multi_head[asyncio]", "tests/test_responses.py::test_file_response_range_multi_head[trio]", "tests/test_responses.py::test_file_response_range_must_be_requested[asyncio]", "tests/test_responses.py::test_file_response_range_must_be_requested[trio]", "tests/test_responses.py::test_file_response_range_without_dash[asyncio]", "tests/test_responses.py::test_file_response_range_without_dash[trio]", "tests/test_responses.py::test_file_response_set_media_type[asyncio]", "tests/test_responses.py::test_file_response_set_media_type[trio]", "tests/test_responses.py::test_file_response_start_must_be_less_than_end[asyncio]", "tests/test_responses.py::test_file_response_start_must_be_less_than_end[trio]", "tests/test_responses.py::test_file_response_suffix_range[asyncio]", "tests/test_responses.py::test_file_response_suffix_range[trio]", "tests/test_responses.py::test_file_response_suffix_range_larger_than_file[asyncio]", "tests/test_responses.py::test_file_response_suffix_range_larger_than_file[trio]", "tests/test_responses.py::test_file_response_with_chinese_filename[asyncio]", "tests/test_responses.py::test_file_response_with_chinese_filename[trio]", "tests/test_responses.py::test_file_response_with_directory_raises_error[asyncio]", "tests/test_responses.py::test_file_response_with_directory_raises_error[trio]", "tests/test_responses.py::test_file_response_with_inline_disposition[asyncio]", "tests/test_responses.py::test_file_response_with_inline_disposition[trio]", "tests/test_responses.py::test_file_response_with_missing_file_raises_error[asyncio]", "tests/test_responses.py::test_file_response_with_missing_file_raises_error[trio]", "tests/test_responses.py::test_file_response_with_pathsend[asyncio]", "tests/test_responses.py::test_file_response_with_pathsend[trio]", "tests/test_responses.py::test_file_response_with_range_header[asyncio]", "tests/test_responses.py::test_file_response_with_range_header[trio]", "tests/test_responses.py::test_file_response_without_range[asyncio]", "tests/test_responses.py::test_file_response_without_range[trio]", "tests/test_responses.py::test_head_method[asyncio]", "tests/test_responses.py::test_head_method[trio]", "tests/test_responses.py::test_json_none_response[asyncio]", "tests/test_responses.py::test_json_none_response[trio]", "tests/test_responses.py::test_non_empty_response[asyncio]", "tests/test_responses.py::test_non_empty_response[trio]", "tests/test_responses.py::test_populate_headers[asyncio]", "tests/test_responses.py::test_populate_headers[trio]", "tests/test_responses.py::test_quoting_redirect_response[asyncio]", "tests/test_responses.py::test_quoting_redirect_response[trio]", "tests/test_responses.py::test_redirect_response[asyncio]", "tests/test_responses.py::test_redirect_response[trio]", "tests/test_responses.py::test_redirect_response_content_length_header[asyncio]", "tests/test_responses.py::test_redirect_response_content_length_header[trio]", "tests/test_responses.py::test_response_do_not_add_redundant_charset[asyncio]", "tests/test_responses.py::test_response_do_not_add_redundant_charset[trio]", "tests/test_responses.py::test_response_headers[asyncio]", "tests/test_responses.py::test_response_headers[trio]", "tests/test_responses.py::test_response_memoryview[asyncio]", "tests/test_responses.py::test_response_memoryview[trio]", "tests/test_responses.py::test_response_phrase[asyncio]", "tests/test_responses.py::test_response_phrase[trio]", "tests/test_responses.py::test_set_cookie[asyncio]", "tests/test_responses.py::test_set_cookie[trio]", "tests/test_responses.py::test_set_cookie_path_none[asyncio]", "tests/test_responses.py::test_set_cookie_path_none[trio]", "tests/test_responses.py::test_set_cookie_raises_for_invalid_python_version[asyncio]", "tests/test_responses.py::test_set_cookie_raises_for_invalid_python_version[trio]", "tests/test_responses.py::test_set_cookie_samesite_none[asyncio]", "tests/test_responses.py::test_set_cookie_samesite_none[trio]", "tests/test_responses.py::test_streaming_response[asyncio]", "tests/test_responses.py::test_streaming_response[trio]", "tests/test_responses.py::test_streaming_response_custom_iterable[asyncio]", "tests/test_responses.py::test_streaming_response_custom_iterable[trio]", "tests/test_responses.py::test_streaming_response_custom_iterator[asyncio]", "tests/test_responses.py::test_streaming_response_custom_iterator[trio]", "tests/test_responses.py::test_streaming_response_known_size[asyncio]", "tests/test_responses.py::test_streaming_response_known_size[trio]", "tests/test_responses.py::test_streaming_response_memoryview[asyncio]", "tests/test_responses.py::test_streaming_response_memoryview[trio]", "tests/test_responses.py::test_streaming_response_on_client_disconnects[asyncio]", "tests/test_responses.py::test_streaming_response_on_client_disconnects[trio]", "tests/test_responses.py::test_streaming_response_runs_background_on_websocket_scope[asyncio]", "tests/test_responses.py::test_streaming_response_runs_background_on_websocket_scope[trio]", "tests/test_responses.py::test_streaming_response_stops_if_receiving_http_disconnect[asyncio]", "tests/test_responses.py::test_streaming_response_stops_if_receiving_http_disconnect[trio]", "tests/test_responses.py::test_streaming_response_unknown_size[asyncio]", "tests/test_responses.py::test_streaming_response_unknown_size[trio]", "tests/test_responses.py::test_sync_streaming_response[asyncio]", "tests/test_responses.py::test_sync_streaming_response[trio]", "tests/test_responses.py::test_text_response[asyncio]", "tests/test_responses.py::test_text_response[trio]", "tests/test_routing.py::test_add_route_to_app_after_mount[asyncio]", "tests/test_routing.py::test_add_route_to_app_after_mount[trio]", "tests/test_routing.py::test_base_route_middleware[asyncio-app0]", "tests/test_routing.py::test_base_route_middleware[asyncio-app1]", "tests/test_routing.py::test_base_route_middleware[asyncio-app2]", "tests/test_routing.py::test_base_route_middleware[trio-app0]", "tests/test_routing.py::test_base_route_middleware[trio-app1]", "tests/test_routing.py::test_base_route_middleware[trio-app2]", "tests/test_routing.py::test_duplicated_param_names", "tests/test_routing.py::test_exception_on_mounted_apps[asyncio]", "tests/test_routing.py::test_exception_on_mounted_apps[trio]", "tests/test_routing.py::test_host_named_repr", "tests/test_routing.py::test_host_repr", "tests/test_routing.py::test_host_reverse_urls", "tests/test_routing.py::test_host_routing[asyncio]", "tests/test_routing.py::test_host_routing[trio]", "tests/test_routing.py::test_lifespan_state_async_cm[asyncio]", "tests/test_routing.py::test_lifespan_state_async_cm[trio]", "tests/test_routing.py::test_lifespan_state_unsupported[asyncio]", "tests/test_routing.py::test_lifespan_state_unsupported[trio]", "tests/test_routing.py::test_mount_asgi_app_with_middleware_url_path_for", "tests/test_routing.py::test_mount_at_root[asyncio]", "tests/test_routing.py::test_mount_at_root[trio]", "tests/test_routing.py::test_mount_named_repr", "tests/test_routing.py::test_mount_repr", "tests/test_routing.py::test_mount_routes_with_middleware_url_path_for", "tests/test_routing.py::test_mount_urls[asyncio]", "tests/test_routing.py::test_mount_urls[trio]", "tests/test_routing.py::test_mounted_middleware_does_not_catch_exception[asyncio]", "tests/test_routing.py::test_mounted_middleware_does_not_catch_exception[trio]", "tests/test_routing.py::test_partial_async_endpoint[asyncio]", "tests/test_routing.py::test_partial_async_endpoint[trio]", "tests/test_routing.py::test_partial_async_ws_endpoint[asyncio]", "tests/test_routing.py::test_partial_async_ws_endpoint[trio]", "tests/test_routing.py::test_paths_with_root_path[asyncio]", "tests/test_routing.py::test_paths_with_root_path[trio]", "tests/test_routing.py::test_protocol_switch[asyncio]", "tests/test_routing.py::test_protocol_switch[trio]", "tests/test_routing.py::test_raise_on_shutdown[asyncio]", "tests/test_routing.py::test_raise_on_shutdown[trio]", "tests/test_routing.py::test_raise_on_startup[asyncio]", "tests/test_routing.py::test_raise_on_startup[trio]", "tests/test_routing.py::test_reverse_mount_urls", "tests/test_routing.py::test_route_converters[asyncio]", "tests/test_routing.py::test_route_converters[trio]", "tests/test_routing.py::test_route_name[classmethod]", "tests/test_routing.py::test_route_name[function]", "tests/test_routing.py::test_route_name[lambda]", "tests/test_routing.py::test_route_name[method]", "tests/test_routing.py::test_route_name[object]", "tests/test_routing.py::test_route_name[staticmethod]", "tests/test_routing.py::test_route_repr", "tests/test_routing.py::test_route_repr_without_methods", "tests/test_routing.py::test_router[asyncio]", "tests/test_routing.py::test_router[trio]", "tests/test_routing.py::test_router_add_route[asyncio]", "tests/test_routing.py::test_router_add_route[trio]", "tests/test_routing.py::test_router_add_websocket_route[asyncio]", "tests/test_routing.py::test_router_add_websocket_route[trio]", "tests/test_routing.py::test_router_duplicate_path[asyncio]", "tests/test_routing.py::test_router_duplicate_path[trio]", "tests/test_routing.py::test_router_middleware[asyncio]", "tests/test_routing.py::test_router_middleware[trio]", "tests/test_routing.py::test_standalone_route_does_not_match[asyncio]", "tests/test_routing.py::test_standalone_route_does_not_match[trio]", "tests/test_routing.py::test_standalone_route_matches[asyncio]", "tests/test_routing.py::test_standalone_route_matches[trio]", "tests/test_routing.py::test_standalone_ws_route_does_not_match[asyncio]", "tests/test_routing.py::test_standalone_ws_route_does_not_match[trio]", "tests/test_routing.py::test_standalone_ws_route_matches[asyncio]", "tests/test_routing.py::test_standalone_ws_route_matches[trio]", "tests/test_routing.py::test_subdomain_reverse_urls", "tests/test_routing.py::test_subdomain_routing[asyncio]", "tests/test_routing.py::test_subdomain_routing[trio]", "tests/test_routing.py::test_url_for", "tests/test_routing.py::test_url_for_with_double_mount", "tests/test_routing.py::test_url_for_with_root_path[asyncio]", "tests/test_routing.py::test_url_for_with_root_path[trio]", "tests/test_routing.py::test_url_for_with_root_path_ending_with_slash[asyncio]", "tests/test_routing.py::test_url_for_with_root_path_ending_with_slash[trio]", "tests/test_routing.py::test_url_path_for", "tests/test_routing.py::test_websocket_route_middleware[asyncio]", "tests/test_routing.py::test_websocket_route_middleware[trio]", "tests/test_routing.py::test_websocket_route_repr", "tests/test_schemas.py::test_schema_endpoint[asyncio]", "tests/test_schemas.py::test_schema_endpoint[trio]", "tests/test_schemas.py::test_schema_generation", "tests/test_staticfiles.py::test_staticfiles[asyncio]", "tests/test_staticfiles.py::test_staticfiles[trio]", "tests/test_staticfiles.py::test_staticfiles_200_with_etag_mismatch[asyncio]", "tests/test_staticfiles.py::test_staticfiles_200_with_etag_mismatch[trio]", "tests/test_staticfiles.py::test_staticfiles_200_with_etag_mismatch_and_timestamp_match[asyncio]", "tests/test_staticfiles.py::test_staticfiles_200_with_etag_mismatch_and_timestamp_match[trio]", "tests/test_staticfiles.py::test_staticfiles_304_with_etag_match[asyncio]", "tests/test_staticfiles.py::test_staticfiles_304_with_etag_match[trio]", "tests/test_staticfiles.py::test_staticfiles_304_with_last_modified_compare_last_req[asyncio]", "tests/test_staticfiles.py::test_staticfiles_304_with_last_modified_compare_last_req[trio]", "tests/test_staticfiles.py::test_staticfiles_access_file_as_dir_returns_404[asyncio]", "tests/test_staticfiles.py::test_staticfiles_access_file_as_dir_returns_404[trio]", "tests/test_staticfiles.py::test_staticfiles_avoids_path_traversal", "tests/test_staticfiles.py::test_staticfiles_cache_invalidation_for_deleted_file_html_mode[asyncio]", "tests/test_staticfiles.py::test_staticfiles_cache_invalidation_for_deleted_file_html_mode[trio]", "tests/test_staticfiles.py::test_staticfiles_config_check_occurs_only_once[asyncio]", "tests/test_staticfiles.py::test_staticfiles_config_check_occurs_only_once[trio]", "tests/test_staticfiles.py::test_staticfiles_configured_with_file_instead_of_directory[asyncio]", "tests/test_staticfiles.py::test_staticfiles_configured_with_file_instead_of_directory[trio]", "tests/test_staticfiles.py::test_staticfiles_configured_with_missing_directory[asyncio]", "tests/test_staticfiles.py::test_staticfiles_configured_with_missing_directory[trio]", "tests/test_staticfiles.py::test_staticfiles_disallows_path_traversal_with_symlinks", "tests/test_staticfiles.py::test_staticfiles_filename_too_long[asyncio]", "tests/test_staticfiles.py::test_staticfiles_filename_too_long[trio]", "tests/test_staticfiles.py::test_staticfiles_follows_symlink_directories[asyncio]", "tests/test_staticfiles.py::test_staticfiles_follows_symlink_directories[trio]", "tests/test_staticfiles.py::test_staticfiles_follows_symlinks[asyncio]", "tests/test_staticfiles.py::test_staticfiles_follows_symlinks[trio]", "tests/test_staticfiles.py::test_staticfiles_head_with_middleware[asyncio]", "tests/test_staticfiles.py::test_staticfiles_head_with_middleware[trio]", "tests/test_staticfiles.py::test_staticfiles_html_normal[asyncio]", "tests/test_staticfiles.py::test_staticfiles_html_normal[trio]", "tests/test_staticfiles.py::test_staticfiles_html_only_files[asyncio]", "tests/test_staticfiles.py::test_staticfiles_html_only_files[trio]", "tests/test_staticfiles.py::test_staticfiles_html_without_404[asyncio]", "tests/test_staticfiles.py::test_staticfiles_html_without_404[trio]", "tests/test_staticfiles.py::test_staticfiles_html_without_index[asyncio]", "tests/test_staticfiles.py::test_staticfiles_html_without_index[trio]", "tests/test_staticfiles.py::test_staticfiles_instantiated_with_missing_directory", "tests/test_staticfiles.py::test_staticfiles_never_read_file_for_head_method[asyncio]", "tests/test_staticfiles.py::test_staticfiles_never_read_file_for_head_method[trio]", "tests/test_staticfiles.py::test_staticfiles_null_byte_in_path[asyncio]", "tests/test_staticfiles.py::test_staticfiles_null_byte_in_path[trio]", "tests/test_staticfiles.py::test_staticfiles_post[asyncio]", "tests/test_staticfiles.py::test_staticfiles_post[trio]", "tests/test_staticfiles.py::test_staticfiles_prevents_breaking_out_of_directory", "tests/test_staticfiles.py::test_staticfiles_rejects_absolute_paths", "tests/test_staticfiles.py::test_staticfiles_rejects_absolute_windows_paths", "tests/test_staticfiles.py::test_staticfiles_relative_directory_symlinks[asyncio]", "tests/test_staticfiles.py::test_staticfiles_relative_directory_symlinks[trio]", "tests/test_staticfiles.py::test_staticfiles_self_symlinks[asyncio]", "tests/test_staticfiles.py::test_staticfiles_self_symlinks[trio]", "tests/test_staticfiles.py::test_staticfiles_unhandled_os_error_returns_500[asyncio]", "tests/test_staticfiles.py::test_staticfiles_unhandled_os_error_returns_500[trio]", "tests/test_staticfiles.py::test_staticfiles_with_directory_returns_404[asyncio]", "tests/test_staticfiles.py::test_staticfiles_with_directory_returns_404[trio]", "tests/test_staticfiles.py::test_staticfiles_with_invalid_dir_permissions_returns_401[asyncio]", "tests/test_staticfiles.py::test_staticfiles_with_invalid_dir_permissions_returns_401[trio]", "tests/test_staticfiles.py::test_staticfiles_with_missing_dir_returns_404[asyncio]", "tests/test_staticfiles.py::test_staticfiles_with_missing_dir_returns_404[trio]", "tests/test_staticfiles.py::test_staticfiles_with_missing_file_returns_404[asyncio]", "tests/test_staticfiles.py::test_staticfiles_with_missing_file_returns_404[trio]", "tests/test_staticfiles.py::test_staticfiles_with_package[asyncio]", "tests/test_staticfiles.py::test_staticfiles_with_package[trio]", "tests/test_staticfiles.py::test_staticfiles_with_pathlib[asyncio]", "tests/test_staticfiles.py::test_staticfiles_with_pathlib[trio]", "tests/test_status.py::test_deprecated_types[HTTP_413_REQUEST_ENTITY_TOO_LARGE-'HTTP_413_REQUEST_ENTITY_TOO_LARGE' is deprecated. Use 'HTTP_413_CONTENT_TOO_LARGE' instead.]", "tests/test_status.py::test_deprecated_types[HTTP_414_REQUEST_URI_TOO_LONG-'HTTP_414_REQUEST_URI_TOO_LONG' is deprecated. Use 'HTTP_414_URI_TOO_LONG' instead.]", "tests/test_status.py::test_unknown_status", "tests/test_templates.py::test_calls_context_processors[asyncio]", "tests/test_templates.py::test_calls_context_processors[trio]", "tests/test_templates.py::test_template_with_middleware[asyncio]", "tests/test_templates.py::test_template_with_middleware[trio]", "tests/test_templates.py::test_templates[asyncio]", "tests/test_templates.py::test_templates[trio]", "tests/test_templates.py::test_templates_autoescape", "tests/test_templates.py::test_templates_require_directory_or_environment", "tests/test_templates.py::test_templates_require_directory_or_environment_not_both", "tests/test_templates.py::test_templates_with_directories[asyncio]", "tests/test_templates.py::test_templates_with_directories[trio]", "tests/test_templates.py::test_templates_with_directory", "tests/test_templates.py::test_templates_with_environment[asyncio]", "tests/test_templates.py::test_templates_with_environment[trio]", "tests/test_testclient.py::test_client[asyncio]", "tests/test_testclient.py::test_client[trio]", "tests/test_testclient.py::test_client_custom_client[asyncio]", "tests/test_testclient.py::test_client_custom_client[trio]", "tests/test_testclient.py::test_domain_restricted_cookies[asyncio-example.com-False]", "tests/test_testclient.py::test_domain_restricted_cookies[asyncio-localhost-False]", "tests/test_testclient.py::test_domain_restricted_cookies[asyncio-testserver-True]", "tests/test_testclient.py::test_domain_restricted_cookies[asyncio-testserver.local-True]", "tests/test_testclient.py::test_domain_restricted_cookies[trio-example.com-False]", "tests/test_testclient.py::test_domain_restricted_cookies[trio-localhost-False]", "tests/test_testclient.py::test_domain_restricted_cookies[trio-testserver-True]", "tests/test_testclient.py::test_domain_restricted_cookies[trio-testserver.local-True]", "tests/test_testclient.py::test_error_on_startup[asyncio]", "tests/test_testclient.py::test_error_on_startup[trio]", "tests/test_testclient.py::test_exception_in_middleware[asyncio]", "tests/test_testclient.py::test_exception_in_middleware[trio]", "tests/test_testclient.py::test_forward_follow_redirects[asyncio]", "tests/test_testclient.py::test_forward_follow_redirects[trio]", "tests/test_testclient.py::test_forward_nofollow_redirects[asyncio]", "tests/test_testclient.py::test_forward_nofollow_redirects[trio]", "tests/test_testclient.py::test_merge_url[asyncio]", "tests/test_testclient.py::test_merge_url[trio]", "tests/test_testclient.py::test_query_params[asyncio-2020-07-14T00:00:00+00:00]", "tests/test_testclient.py::test_query_params[asyncio-Espa\\xf1a]", "tests/test_testclient.py::test_query_params[asyncio-voil\\xe0]", "tests/test_testclient.py::test_query_params[trio-2020-07-14T00:00:00+00:00]", "tests/test_testclient.py::test_query_params[trio-Espa\\xf1a]", "tests/test_testclient.py::test_query_params[trio-voil\\xe0]", "tests/test_testclient.py::test_raw_path_with_querystring[asyncio]", "tests/test_testclient.py::test_raw_path_with_querystring[trio]", "tests/test_testclient.py::test_testclient_asgi2[asyncio]", "tests/test_testclient.py::test_testclient_asgi2[trio]", "tests/test_testclient.py::test_testclient_asgi3[asyncio]", "tests/test_testclient.py::test_testclient_asgi3[trio]", "tests/test_testclient.py::test_testclient_headers_behavior", "tests/test_testclient.py::test_timeout_deprecation", "tests/test_testclient.py::test_use_testclient_as_contextmanager[asyncio]", "tests/test_testclient.py::test_use_testclient_as_contextmanager[trio]", "tests/test_testclient.py::test_use_testclient_in_endpoint[asyncio]", "tests/test_testclient.py::test_use_testclient_in_endpoint[trio]", "tests/test_testclient.py::test_websocket_blocking_receive[asyncio]", "tests/test_testclient.py::test_websocket_blocking_receive[trio]", "tests/test_testclient.py::test_websocket_not_block_on_close[asyncio]", "tests/test_testclient.py::test_websocket_not_block_on_close[trio]", "tests/test_testclient.py::test_websocket_raw_path_without_params[asyncio]", "tests/test_testclient.py::test_websocket_raw_path_without_params[trio]", "tests/test_testclient.py::test_with_duplicate_headers[asyncio]", "tests/test_testclient.py::test_with_duplicate_headers[trio]", "tests/test_websockets.py::test_additional_headers[asyncio]", "tests/test_websockets.py::test_additional_headers[trio]", "tests/test_websockets.py::test_application_close[asyncio]", "tests/test_websockets.py::test_application_close[trio]", "tests/test_websockets.py::test_client_close[asyncio]", "tests/test_websockets.py::test_client_close[trio]", "tests/test_websockets.py::test_client_disconnect_on_send[asyncio]", "tests/test_websockets.py::test_client_disconnect_on_send[trio]", "tests/test_websockets.py::test_duplicate_close[asyncio]", "tests/test_websockets.py::test_duplicate_close[trio]", "tests/test_websockets.py::test_duplicate_disconnect[asyncio]", "tests/test_websockets.py::test_duplicate_disconnect[trio]", "tests/test_websockets.py::test_no_additional_headers[asyncio]", "tests/test_websockets.py::test_no_additional_headers[trio]", "tests/test_websockets.py::test_receive_before_accept[asyncio]", "tests/test_websockets.py::test_receive_before_accept[trio]", "tests/test_websockets.py::test_receive_bytes_before_accept[asyncio]", "tests/test_websockets.py::test_receive_bytes_before_accept[trio]", "tests/test_websockets.py::test_receive_json_before_accept[asyncio]", "tests/test_websockets.py::test_receive_json_before_accept[trio]", "tests/test_websockets.py::test_receive_json_invalid_mode[asyncio]", "tests/test_websockets.py::test_receive_json_invalid_mode[trio]", "tests/test_websockets.py::test_receive_text_before_accept[asyncio]", "tests/test_websockets.py::test_receive_text_before_accept[trio]", "tests/test_websockets.py::test_receive_wrong_message_type[asyncio]", "tests/test_websockets.py::test_receive_wrong_message_type[trio]", "tests/test_websockets.py::test_rejected_connection[asyncio]", "tests/test_websockets.py::test_rejected_connection[trio]", "tests/test_websockets.py::test_send_before_accept[asyncio]", "tests/test_websockets.py::test_send_before_accept[trio]", "tests/test_websockets.py::test_send_denial_response[asyncio]", "tests/test_websockets.py::test_send_denial_response[trio]", "tests/test_websockets.py::test_send_denial_response_with_file_response[asyncio]", "tests/test_websockets.py::test_send_denial_response_with_file_response[trio]", "tests/test_websockets.py::test_send_denial_response_with_streaming_response[asyncio]", "tests/test_websockets.py::test_send_denial_response_with_streaming_response[trio]", "tests/test_websockets.py::test_send_json_invalid_mode[asyncio]", "tests/test_websockets.py::test_send_json_invalid_mode[trio]", "tests/test_websockets.py::test_send_response_duplicate_start[asyncio]", "tests/test_websockets.py::test_send_response_duplicate_start[trio]", "tests/test_websockets.py::test_send_response_multi[asyncio]", "tests/test_websockets.py::test_send_response_multi[trio]", "tests/test_websockets.py::test_send_response_unsupported[asyncio]", "tests/test_websockets.py::test_send_response_unsupported[trio]", "tests/test_websockets.py::test_send_wrong_message_type[asyncio]", "tests/test_websockets.py::test_send_wrong_message_type[trio]", "tests/test_websockets.py::test_subprotocol[asyncio]", "tests/test_websockets.py::test_subprotocol[trio]", "tests/test_websockets.py::test_websocket_binary_json[asyncio]", "tests/test_websockets.py::test_websocket_binary_json[trio]", "tests/test_websockets.py::test_websocket_close_reason[asyncio]", "tests/test_websockets.py::test_websocket_close_reason[trio]", "tests/test_websockets.py::test_websocket_concurrency_pattern[asyncio]", "tests/test_websockets.py::test_websocket_concurrency_pattern[trio]", "tests/test_websockets.py::test_websocket_ensure_unicode_on_send_json[asyncio]", "tests/test_websockets.py::test_websocket_ensure_unicode_on_send_json[trio]", "tests/test_websockets.py::test_websocket_exception[asyncio]", "tests/test_websockets.py::test_websocket_exception[trio]", "tests/test_websockets.py::test_websocket_headers[asyncio]", "tests/test_websockets.py::test_websocket_headers[trio]", "tests/test_websockets.py::test_websocket_iter_bytes[asyncio]", "tests/test_websockets.py::test_websocket_iter_bytes[trio]", "tests/test_websockets.py::test_websocket_iter_json[asyncio]", "tests/test_websockets.py::test_websocket_iter_json[trio]", "tests/test_websockets.py::test_websocket_iter_text[asyncio]", "tests/test_websockets.py::test_websocket_iter_text[trio]", "tests/test_websockets.py::test_websocket_port[asyncio]", "tests/test_websockets.py::test_websocket_port[trio]", "tests/test_websockets.py::test_websocket_query_params[asyncio]", "tests/test_websockets.py::test_websocket_query_params[trio]", "tests/test_websockets.py::test_websocket_scope_interface", "tests/test_websockets.py::test_websocket_send_and_receive_bytes[asyncio]", "tests/test_websockets.py::test_websocket_send_and_receive_bytes[trio]", "tests/test_websockets.py::test_websocket_send_and_receive_json[asyncio]", "tests/test_websockets.py::test_websocket_send_and_receive_json[trio]", "tests/test_websockets.py::test_websocket_send_and_receive_text[asyncio]", "tests/test_websockets.py::test_websocket_send_and_receive_text[trio]", "tests/test_websockets.py::test_websocket_url[asyncio]", "tests/test_websockets.py::test_websocket_url[trio]"], "notes": "Requirement texts are not yet written for mined triples; the pull requests are given instead. Each B is ported onto S+A on its own; tests_* hold the gzip test file at S+A, S+A+B1 and S+A+B2. See mining/README.md."}
{"instance_id": "fuse-dev/strix-733", "repository": "https://github.com/usestrix/strix", "license": "Apache-2.0", "status": "development triple: fully eligible", "criterion_3": "B1 and B2 each rewrite lines A wrote (git blame at S+A). Neither needs A to pass its own tests, so the dependence is textual.", "snapshot_commit": "c13960ae01a355a42cf35e3a01d2791fcec7a317", "commit_A": "205e0b370706283cee4bcd6d7d8ca7faf41e9d23", "commit_B1": "62b496430da5df5e9e79a190e7af6f92529883a3", "commit_B2": "3a3855fc4f0ecd0e7d15488afb29a779162eba85", "pull_request_A": "https://github.com/usestrix/strix/pull/733", "pull_request_B1": "https://github.com/usestrix/strix/pull/1496", "pull_request_B2": "https://github.com/usestrix/strix/pull/1550", "patch_A": "diff --git a/strix/agents/factory.py b/strix/agents/factory.py\nindex 6a5af17..6564267 100644\n--- a/strix/agents/factory.py\n+++ b/strix/agents/factory.py\n@@ -55,7 +55,7 @@ from strix.tools.web_search.tool import web_search\n \n \n if TYPE_CHECKING:\n- from collections.abc import Awaitable, Callable\n+ from collections.abc import Awaitable, Callable, Sequence\n \n from agents import RunContextWrapper\n from agents.tool import FunctionToolResult\n@@ -349,6 +349,48 @@ _BASE_TOOLS: tuple[Tool, ...] = (\n )\n \n \n+# Extra tools registered for scan agents. Mirrors\n+# ``strix.runtime.backends.register_backend``: register before the first\n+# ``build_strix_agent`` call and every agent (root + children) gets them.\n+_EXTRA_TOOLS: list[Tool] = []\n+\n+\n+def _ensure_unique_tool_names(tools: Sequence[Tool]) -> None:\n+ seen: set[str] = set()\n+ duplicates: set[str] = set()\n+ for tool in tools:\n+ if tool.name in seen:\n+ duplicates.add(tool.name)\n+ seen.add(tool.name)\n+ if duplicates:\n+ msg = f\"Agent tools must have unique names: {sorted(duplicates)}\"\n+ raise ValueError(msg)\n+\n+\n+def register_agent_tools(*tools: Tool) -> None:\n+ \"\"\"Register tools for every scan agent built afterwards.\n+\n+ Tools are added to both root and child agents, after the base set and\n+ before the lifecycle tool (``finish_scan`` / ``agent_finish``). Duplicate\n+ tool objects are ignored so repeated imports don't double-register.\n+ \"\"\"\n+ new_tools: list[Tool] = []\n+ for tool in tools:\n+ if tool not in _EXTRA_TOOLS and tool not in new_tools:\n+ new_tools.append(tool)\n+\n+ _ensure_unique_tool_names([*_BASE_TOOLS, *_EXTRA_TOOLS, *new_tools, finish_scan, agent_finish])\n+\n+ for tool in new_tools:\n+ _EXTRA_TOOLS.append(tool)\n+ logger.info(\"Registered extra agent tool: %s\", getattr(tool, \"name\", tool))\n+\n+\n+def registered_agent_tools() -> tuple[Tool, ...]:\n+ \"\"\"Return the currently registered scan-agent tools.\"\"\"\n+ return tuple(_EXTRA_TOOLS)\n+\n+\n def build_strix_agent(\n *,\n name: str = \"strix\",\n@@ -359,26 +401,37 @@ def build_strix_agent(\n interactive: bool = False,\n chat_completions_tools: bool = False,\n system_prompt_context: dict[str, Any] | None = None,\n+ extra_tools: Sequence[Tool] | None = None,\n+ instructions_override: str | None = None,\n ) -> SandboxAgent[Any]:\n \"\"\"Build a SandboxAgent for either root or child use.\n \n Args:\n chat_completions_tools: Wrap SDK custom tools as function tools\n when the selected backend cannot accept Responses custom tools.\n+ extra_tools: Additional tools for this scan agent only, on top of any\n+ registered via ``register_agent_tools``.\n+ instructions_override: Use this verbatim as the system prompt instead\n+ of rendering the built-in scan prompt.\n \"\"\"\n- instructions = render_system_prompt(\n- skills=skills,\n- scan_mode=scan_mode,\n- is_whitebox=is_whitebox,\n- is_root=is_root,\n- interactive=interactive,\n- system_prompt_context=system_prompt_context,\n- )\n+ if instructions_override is not None:\n+ instructions = instructions_override\n+ else:\n+ instructions = render_system_prompt(\n+ skills=skills,\n+ scan_mode=scan_mode,\n+ is_whitebox=is_whitebox,\n+ is_root=is_root,\n+ interactive=interactive,\n+ system_prompt_context=system_prompt_context,\n+ )\n \n+ agent_tools = [*_EXTRA_TOOLS, *(extra_tools or [])]\n if is_root:\n- tools: list[Tool] = [*_BASE_TOOLS, finish_scan]\n+ tools: list[Tool] = [*_BASE_TOOLS, *agent_tools, finish_scan]\n else:\n- tools = [*_BASE_TOOLS, agent_finish]\n+ tools = [*_BASE_TOOLS, *agent_tools, agent_finish]\n+ _ensure_unique_tool_names(tools)\n \n logger.info(\n \"Built %s agent '%s' (skills=%d, tools=%d, scan_mode=%s, whitebox=%s)\",\ndiff --git a/tests/test_agent_tool_registration.py b/tests/test_agent_tool_registration.py\nnew file mode 100644\nindex 0000000..8c7d67d\n--- /dev/null\n+++ b/tests/test_agent_tool_registration.py\n@@ -0,0 +1,88 @@\n+\"\"\"Tests for scan-agent tool registration in factory.\"\"\"\n+\n+from __future__ import annotations\n+\n+import pytest\n+from agents.tool import FunctionTool\n+\n+from strix.agents import factory\n+\n+\n+def _tool(name: str) -> FunctionTool:\n+ return FunctionTool(\n+ name=name,\n+ description=\"test tool\",\n+ params_json_schema={\"type\": \"object\", \"properties\": {}, \"additionalProperties\": False},\n+ on_invoke_tool=lambda _ctx, _inp: \"ok\",\n+ )\n+\n+\n+@pytest.fixture(autouse=True)\n+def _reset_registry() -> object:\n+ saved = list(factory._EXTRA_TOOLS)\n+ factory._EXTRA_TOOLS.clear()\n+ try:\n+ yield\n+ finally:\n+ factory._EXTRA_TOOLS[:] = saved\n+\n+\n+def test_register_agent_tools_is_deduped() -> None:\n+ tool = _tool(\"dup\")\n+ factory.register_agent_tools(tool)\n+ factory.register_agent_tools(tool)\n+ assert factory.registered_agent_tools() == (tool,)\n+\n+\n+def test_registered_tools_appear_before_lifecycle_tool() -> None:\n+ tool = _tool(\"extra\")\n+ factory.register_agent_tools(tool)\n+\n+ root = factory.build_strix_agent(is_root=True)\n+ child = factory.build_strix_agent(is_root=False)\n+\n+ root_names = [t.name for t in root.tools]\n+ child_names = [t.name for t in child.tools]\n+\n+ assert root_names[-2:] == [\"extra\", \"finish_scan\"]\n+ assert child_names[-2:] == [\"extra\", \"agent_finish\"]\n+\n+\n+def test_per_call_extra_tools_stack_with_registry() -> None:\n+ factory.register_agent_tools(_tool(\"registered\"))\n+\n+ agent = factory.build_strix_agent(is_root=True, extra_tools=[_tool(\"per_call\")])\n+ names = [t.name for t in agent.tools]\n+\n+ assert \"registered\" in names\n+ assert \"per_call\" in names\n+ assert names[-1] == \"finish_scan\"\n+\n+\n+def test_register_agent_tools_rejects_duplicate_names() -> None:\n+ factory.register_agent_tools(_tool(\"same_name\"))\n+\n+ with pytest.raises(ValueError, match=\"same_name\"):\n+ factory.register_agent_tools(_tool(\"same_name\"))\n+\n+\n+def test_per_call_extra_tools_reject_duplicate_registered_names() -> None:\n+ factory.register_agent_tools(_tool(\"same_name\"))\n+\n+ with pytest.raises(ValueError, match=\"same_name\"):\n+ factory.build_strix_agent(is_root=True, extra_tools=[_tool(\"same_name\")])\n+\n+\n+def test_instructions_override_is_used_verbatim() -> None:\n+ custom = \"You are a scan agent. Follow the provided scope.\"\n+\n+ agent = factory.build_strix_agent(is_root=True, instructions_override=custom)\n+\n+ assert agent.instructions == custom\n+\n+\n+def test_no_override_renders_builtin_prompt() -> None:\n+ agent = factory.build_strix_agent(is_root=True)\n+\n+ assert isinstance(agent.instructions, str)\n+ assert agent.instructions != \"\"\n", "patch_B1": "diff --git a/strix/agents/factory.py b/strix/agents/factory.py\nindex 6564267..e946a05 100644\n--- a/strix/agents/factory.py\n+++ b/strix/agents/factory.py\n@@ -403,6 +403,7 @@ def build_strix_agent(\n system_prompt_context: dict[str, Any] | None = None,\n extra_tools: Sequence[Tool] | None = None,\n instructions_override: str | None = None,\n+ finish_tool: Tool = finish_scan,\n ) -> SandboxAgent[Any]:\n \"\"\"Build a SandboxAgent for either root or child use.\n \n@@ -413,6 +414,7 @@ def build_strix_agent(\n registered via ``register_agent_tools``.\n instructions_override: Use this verbatim as the system prompt instead\n of rendering the built-in scan prompt.\n+ finish_tool: The tool that ends the run, given to the root agent.\n \"\"\"\n if instructions_override is not None:\n instructions = instructions_override\n@@ -428,7 +430,7 @@ def build_strix_agent(\n \n agent_tools = [*_EXTRA_TOOLS, *(extra_tools or [])]\n if is_root:\n- tools: list[Tool] = [*_BASE_TOOLS, *agent_tools, finish_scan]\n+ tools: list[Tool] = [*_BASE_TOOLS, *agent_tools, finish_tool]\n else:\n tools = [*_BASE_TOOLS, *agent_tools, agent_finish]\n _ensure_unique_tool_names(tools)\ndiff --git a/strix/core/agents.py b/strix/core/agents.py\nindex 24a7185..3c57982 100644\n--- a/strix/core/agents.py\n+++ b/strix/core/agents.py\n@@ -43,6 +43,7 @@ class AgentCoordinator:\n self._lock = asyncio.Lock()\n self._snapshot_path: Path | None = None\n self.is_shutting_down = False\n+ self.root_finish_tool = \"finish_scan\"\n self._budget_stopped = False\n \n def set_snapshot_path(self, path: Path) -> None:\ndiff --git a/strix/core/execution.py b/strix/core/execution.py\nindex 06dc3dd..d79fb38 100644\n--- a/strix/core/execution.py\n+++ b/strix/core/execution.py\n@@ -326,6 +326,7 @@ async def _run_noninteractive_until_lifecycle(\n input_data = await _append_noninteractive_tool_required_message(\n session=session,\n context=context,\n+ root_finish_tool=coordinator.root_finish_tool,\n attempt=invalid_final_outputs,\n limit=invalid_final_output_limit,\n )\n@@ -474,8 +475,9 @@ async def _append_noninteractive_tool_required_message(\n context: dict[str, Any],\n attempt: int,\n limit: int,\n+ root_finish_tool: str = \"finish_scan\",\n ) -> list[dict[str, str]]:\n- finish_tool = \"finish_scan\" if context.get(\"parent_id\") is None else \"agent_finish\"\n+ finish_tool = root_finish_tool if context.get(\"parent_id\") is None else \"agent_finish\"\n message = (\n \"Your previous response ended the autonomous Strix run without a lifecycle tool call. \"\n \"That is invalid in non-interactive mode; plain text final answers are ignored. \"\ndiff --git a/strix/core/runner.py b/strix/core/runner.py\nindex 13052b6..5bd18ba 100644\n--- a/strix/core/runner.py\n+++ b/strix/core/runner.py\n@@ -39,11 +39,13 @@ from strix.core.paths import run_dir_for, runtime_state_dir\n from strix.core.sessions import open_agent_session\n from strix.runtime import session_manager\n from strix.telemetry.logging import set_scan_id, setup_scan_logging\n+from strix.tools.finish.tool import finish_scan\n \n \n if TYPE_CHECKING:\n from agents.memory import SQLiteSession\n from agents.result import RunResultBase\n+ from agents.tool import Tool\n \n \n logger = logging.getLogger(__name__)\n@@ -64,8 +66,12 @@ async def run_strix_scan(\n model: str | None = None,\n cleanup_on_exit: bool = True,\n event_sink: StreamEventSink | None = None,\n+ root_finish_tool: Tool = finish_scan,\n ) -> RunResultBase | None:\n- \"\"\"Run or resume one Strix scan against a sandbox.\"\"\"\n+ \"\"\"Run or resume one Strix scan against a sandbox.\n+\n+ ``root_finish_tool`` is the tool the root agent ends the run with.\n+ \"\"\"\n if scan_id is None:\n scan_id = f\"scan-{uuid.uuid4().hex[:8]}\"\n \n@@ -103,6 +109,7 @@ async def run_strix_scan(\n if coordinator is None:\n coordinator = AgentCoordinator()\n coordinator.set_snapshot_path(agents_path)\n+ coordinator.root_finish_tool = root_finish_tool.name\n \n from strix.tools.notes.tools import hydrate_notes_from_disk\n from strix.tools.todo.tools import hydrate_todos_from_disk\n@@ -180,6 +187,7 @@ async def run_strix_scan(\n interactive=interactive,\n chat_completions_tools=chat_completions_tools,\n system_prompt_context=scope_context,\n+ finish_tool=root_finish_tool,\n )\n \n if not is_resume:\ndiff --git a/strix/tools/agents_graph/tools.py b/strix/tools/agents_graph/tools.py\nindex 5c1bfd4..4dc5289 100644\n--- a/strix/tools/agents_graph/tools.py\n+++ b/strix/tools/agents_graph/tools.py\n@@ -520,7 +520,8 @@ async def agent_finish(\n {\n \"success\": False,\n \"error\": (\n- \"agent_finish is for subagents. Root/main agents must call finish_scan instead\"\n+ \"agent_finish is for subagents. Root/main agents must call \"\n+ f\"{coordinator.root_finish_tool} instead\"\n ),\n },\n ensure_ascii=False,\ndiff --git a/tests/test_agent_tool_registration.py b/tests/test_agent_tool_registration.py\nindex 8c7d67d..85958cf 100644\n--- a/tests/test_agent_tool_registration.py\n+++ b/tests/test_agent_tool_registration.py\n@@ -48,6 +48,15 @@ def test_registered_tools_appear_before_lifecycle_tool() -> None:\n assert child_names[-2:] == [\"extra\", \"agent_finish\"]\n \n \n+def test_root_ends_with_the_given_finish_tool() -> None:\n+ root = factory.build_strix_agent(is_root=True, finish_tool=_tool(\"finish_pr_review\"))\n+\n+ root_names = [t.name for t in root.tools]\n+\n+ assert root_names[-1] == \"finish_pr_review\"\n+ assert \"finish_scan\" not in root_names\n+\n+\n def test_per_call_extra_tools_stack_with_registry() -> None:\n factory.register_agent_tools(_tool(\"registered\"))\n \ndiff --git a/tests/test_execution.py b/tests/test_execution.py\nindex 59a37e6..61e7a65 100644\n--- a/tests/test_execution.py\n+++ b/tests/test_execution.py\n@@ -42,3 +42,19 @@ async def test_wait_for_message_returns_immediately_after_budget_stop() -> None:\n \n # No pending messages, but the stop flag short-circuits the wait.\n await asyncio.wait_for(coordinator.wait_for_message(\"agent\"), timeout=1.0)\n+\n+\n+@pytest.mark.asyncio\n+async def test_nudge_names_the_root_finish_tool() -> None:\n+ from strix.core.execution import _append_noninteractive_tool_required_message\n+\n+ items = await _append_noninteractive_tool_required_message(\n+ session=None,\n+ context={\"parent_id\": None},\n+ attempt=1,\n+ limit=3,\n+ root_finish_tool=\"finish_pr_review\",\n+ )\n+\n+ assert \"call finish_pr_review\" in items[0][\"content\"]\n+ assert \"finish_scan\" not in items[0][\"content\"]\n", "patch_B2": "diff --git a/strix/agents/factory.py b/strix/agents/factory.py\nindex 6564267..bc06d8a 100644\n--- a/strix/agents/factory.py\n+++ b/strix/agents/factory.py\n@@ -403,6 +403,7 @@ def build_strix_agent(\n system_prompt_context: dict[str, Any] | None = None,\n extra_tools: Sequence[Tool] | None = None,\n instructions_override: str | None = None,\n+ report_tool: Tool = create_vulnerability_report,\n ) -> SandboxAgent[Any]:\n \"\"\"Build a SandboxAgent for either root or child use.\n \n@@ -413,6 +414,8 @@ def build_strix_agent(\n registered via ``register_agent_tools``.\n instructions_override: Use this verbatim as the system prompt instead\n of rendering the built-in scan prompt.\n+ report_tool: The tool every agent files findings with, in place of\n+ ``create_vulnerability_report``.\n \"\"\"\n if instructions_override is not None:\n instructions = instructions_override\n@@ -424,13 +427,15 @@ def build_strix_agent(\n is_root=is_root,\n interactive=interactive,\n system_prompt_context=system_prompt_context,\n+ report_tool=report_tool.name,\n )\n \n agent_tools = [*_EXTRA_TOOLS, *(extra_tools or [])]\n+ base_tools = [report_tool if t is create_vulnerability_report else t for t in _BASE_TOOLS]\n if is_root:\n- tools: list[Tool] = [*_BASE_TOOLS, *agent_tools, finish_scan]\n+ tools: list[Tool] = [*base_tools, *agent_tools, finish_scan]\n else:\n- tools = [*_BASE_TOOLS, *agent_tools, agent_finish]\n+ tools = [*base_tools, *agent_tools, agent_finish]\n _ensure_unique_tool_names(tools)\n \n logger.info(\n@@ -471,6 +476,7 @@ def make_child_factory(\n interactive: bool = False,\n chat_completions_tools: bool = False,\n system_prompt_context: dict[str, Any] | None = None,\n+ report_tool: Tool = create_vulnerability_report,\n ) -> Any:\n \"\"\"Return the runner-owned builder used by ``spawn_child_agent``.\n \n@@ -489,6 +495,7 @@ def make_child_factory(\n interactive=interactive,\n chat_completions_tools=chat_completions_tools,\n system_prompt_context=system_prompt_context,\n+ report_tool=report_tool,\n )\n \n return _factory\ndiff --git a/strix/agents/prompt.py b/strix/agents/prompt.py\nindex 5d90217..bf973bd 100644\n--- a/strix/agents/prompt.py\n+++ b/strix/agents/prompt.py\n@@ -65,6 +65,7 @@ def render_system_prompt(\n is_root: bool = False,\n interactive: bool = False,\n system_prompt_context: dict[str, Any] | None = None,\n+ report_tool: str = \"create_vulnerability_report\",\n ) -> str:\n \"\"\"Render the system prompt. Returns empty string on template failure.\"\"\"\n try:\n@@ -92,6 +93,7 @@ def render_system_prompt(\n available_skills=get_available_skills(),\n interactive=interactive,\n system_prompt_context=system_prompt_context or {},\n+ report_tool=report_tool,\n **skill_content,\n )\n except Exception:\ndiff --git a/strix/agents/prompts/system_prompt.jinja b/strix/agents/prompts/system_prompt.jinja\nindex 4a2f55c..a9d848b 100644\n--- a/strix/agents/prompts/system_prompt.jinja\n+++ b/strix/agents/prompts/system_prompt.jinja\n@@ -190,9 +190,9 @@ VALIDATION REQUIREMENTS:\n - Independent verification through subagent\n - Document complete attack chain\n - Keep going until you find something that matters\n-- A vulnerability is ONLY considered reported when a reporting agent uses create_vulnerability_report with full details. Mentions in agent_finish, finish_scan, or generic messages are NOT sufficient\n-- Do NOT patch/fix before reporting: first create the vulnerability report via create_vulnerability_report (by the reporting agent). Only after reporting is completed should fixing/patching proceed\n-- DEDUPLICATION: The create_vulnerability_report tool uses LLM-based deduplication. If it rejects your report as a duplicate, DO NOT attempt to re-submit the same vulnerability. Accept the rejection and move on to testing other areas. The vulnerability has already been reported by another agent\n+- A vulnerability is ONLY considered reported when a reporting agent uses {{ report_tool }} with full details. Mentions in agent_finish, finish_scan, or generic messages are NOT sufficient\n+- Do NOT patch/fix before reporting: first create the vulnerability report via {{ report_tool }} (by the reporting agent). Only after reporting is completed should fixing/patching proceed\n+- DEDUPLICATION: The {{ report_tool }} tool uses LLM-based deduplication. If it rejects your report as a duplicate, DO NOT attempt to re-submit the same vulnerability. Accept the rejection and move on to testing other areas. The vulnerability has already been reported by another agent\n </execution_guidelines>\n \n <vulnerability_focus>\n@@ -329,7 +329,7 @@ CRITICAL RULES:\n - **REALISTIC OUTCOMES** - Some tests find nothing, some validations fail\n - **ONE AGENT = ONE TASK** - Don't let agents do multiple unrelated jobs\n - **SPAWN REACTIVELY** - Create new agents based on what you discover\n-- **ONLY REPORTING AGENTS** can use create_vulnerability_report tool\n+- **ONLY REPORTING AGENTS** can use {{ report_tool }} tool\n - **AGENT SPECIALIZATION MANDATORY** - Each agent must be highly specialized; prefer 1–3 skills, up to 5 for complex contexts\n - **NO GENERIC AGENTS** - Avoid creating broad, multi-purpose agents that dilute focus\n \ndiff --git a/strix/core/runner.py b/strix/core/runner.py\nindex 13052b6..0f7d448 100644\n--- a/strix/core/runner.py\n+++ b/strix/core/runner.py\n@@ -39,11 +39,13 @@ from strix.core.paths import run_dir_for, runtime_state_dir\n from strix.core.sessions import open_agent_session\n from strix.runtime import session_manager\n from strix.telemetry.logging import set_scan_id, setup_scan_logging\n+from strix.tools.reporting.tool import create_vulnerability_report\n \n \n if TYPE_CHECKING:\n from agents.memory import SQLiteSession\n from agents.result import RunResultBase\n+ from agents.tool import Tool\n \n \n logger = logging.getLogger(__name__)\n@@ -64,8 +66,13 @@ async def run_strix_scan(\n model: str | None = None,\n cleanup_on_exit: bool = True,\n event_sink: StreamEventSink | None = None,\n+ report_tool: Tool = create_vulnerability_report,\n ) -> RunResultBase | None:\n- \"\"\"Run or resume one Strix scan against a sandbox.\"\"\"\n+ \"\"\"Run or resume one Strix scan against a sandbox.\n+\n+ ``report_tool`` is the tool every agent files findings with, in place of\n+ ``create_vulnerability_report``.\n+ \"\"\"\n if scan_id is None:\n scan_id = f\"scan-{uuid.uuid4().hex[:8]}\"\n \n@@ -180,6 +187,7 @@ async def run_strix_scan(\n interactive=interactive,\n chat_completions_tools=chat_completions_tools,\n system_prompt_context=scope_context,\n+ report_tool=report_tool,\n )\n \n if not is_resume:\n@@ -197,6 +205,7 @@ async def run_strix_scan(\n interactive=interactive,\n chat_completions_tools=chat_completions_tools,\n system_prompt_context=scope_context,\n+ report_tool=report_tool,\n )\n \n async def spawn_child_agent(**kwargs: Any) -> dict[str, Any]:\ndiff --git a/tests/test_agent_tool_registration.py b/tests/test_agent_tool_registration.py\nindex 8c7d67d..6008a70 100644\n--- a/tests/test_agent_tool_registration.py\n+++ b/tests/test_agent_tool_registration.py\n@@ -73,6 +73,17 @@ def test_per_call_extra_tools_reject_duplicate_registered_names() -> None:\n factory.build_strix_agent(is_root=True, extra_tools=[_tool(\"same_name\")])\n \n \n+def test_report_tool_replaces_create_vulnerability_report() -> None:\n+ for is_root in (True, False):\n+ agent = factory.build_strix_agent(is_root=is_root, report_tool=_tool(\"file_pr_finding\"))\n+ names = [t.name for t in agent.tools]\n+ assert \"file_pr_finding\" in names\n+ assert \"create_vulnerability_report\" not in names\n+ assert isinstance(agent.instructions, str)\n+ assert \"file_pr_finding\" in agent.instructions\n+ assert \"create_vulnerability_report\" not in agent.instructions\n+\n+\n def test_instructions_override_is_used_verbatim() -> None:\n custom = \"You are a scan agent. Follow the provided scope.\"\n \n", "patch_B1_upstream": "diff --git a/strix/agents/factory.py b/strix/agents/factory.py\nindex 3b9dd61..4cd9e03 100644\n--- a/strix/agents/factory.py\n+++ b/strix/agents/factory.py\n@@ -675,6 +675,7 @@ def build_strix_agent(\n extra_tools: Sequence[Tool] | None = None,\n instructions_override: str | None = None,\n supports_images: bool = True,\n+ finish_tool: Tool = finish_scan,\n ) -> SandboxAgent[Any]:\n \"\"\"Build a SandboxAgent for either root or child use.\n \n@@ -687,6 +688,7 @@ def build_strix_agent(\n registered via ``register_agent_tools``.\n instructions_override: Use this verbatim as the system prompt instead\n of rendering the built-in scan prompt.\n+ finish_tool: The tool that ends the run, given to the root agent.\n \"\"\"\n if instructions_override is not None:\n instructions = instructions_override\n@@ -707,7 +709,7 @@ def build_strix_agent(\n # Yielding to the user is only meaningful when one is attached.\n agent_tools.append(wait_for_user)\n if is_root:\n- tools: list[Tool] = [*_BASE_TOOLS, *agent_tools, finish_scan]\n+ tools: list[Tool] = [*_BASE_TOOLS, *agent_tools, finish_tool]\n else:\n tools = [*_BASE_TOOLS, *agent_tools, agent_finish]\n _ensure_unique_tool_names(tools)\ndiff --git a/strix/core/agents.py b/strix/core/agents.py\nindex efd7cb6..7e738be 100644\n--- a/strix/core/agents.py\n+++ b/strix/core/agents.py\n@@ -71,6 +71,7 @@ class AgentCoordinator:\n self._lock = asyncio.Lock()\n self._snapshot_path: Path | None = None\n self.is_shutting_down = False\n+ self.root_finish_tool = \"finish_scan\"\n self._budget_stopped = False\n self._reserve_stopped = False\n self._budget_paused = False\ndiff --git a/strix/core/execution.py b/strix/core/execution.py\nindex 5997e3d..87a2bf0 100644\n--- a/strix/core/execution.py\n+++ b/strix/core/execution.py\n@@ -302,7 +302,7 @@ async def _run_agent_loop(\n raise SubagentBudgetReservedError(\"scan reached the sub-agent budget reserve\")\n \n if reserve_stopped and start_parked and interactive and context.get(\"parent_id\") is None:\n- await coordinator.send(agent_id, _reserve_notice())\n+ await coordinator.send(agent_id, _reserve_notice(coordinator.root_finish_tool))\n \n if not (start_parked and interactive):\n with contextlib.suppress(BudgetPausedError):\n@@ -642,6 +642,7 @@ async def _run_until_lifecycle(\n input_data = await _append_tool_required_message(\n session=session,\n context=context,\n+ root_finish_tool=coordinator.root_finish_tool,\n attempt=recoveries,\n limit=recovery_limit,\n interactive=interactive,\n@@ -988,8 +989,9 @@ async def _append_tool_required_message(\n limit: int,\n interactive: bool,\n silent_yield: bool = False,\n+ root_finish_tool: str = \"finish_scan\",\n ) -> list[dict[str, str]]:\n- finish_tool = \"finish_scan\" if context.get(\"parent_id\") is None else \"agent_finish\"\n+ finish_tool = root_finish_tool if context.get(\"parent_id\") is None else \"agent_finish\"\n if silent_yield:\n message = (\n \"You called wait_for_user without having written anything to the user since \"\n@@ -1107,7 +1109,7 @@ async def notify_parent_on_terminal(\n )\n \n \n-def _reserve_notice() -> dict[str, Any]:\n+def _reserve_notice(finish_tool: str) -> dict[str, Any]:\n return {\n \"from\": \"system\",\n \"type\": \"budget_reserve_stop\",\n@@ -1117,7 +1119,7 @@ def _reserve_notice() -> dict[str, Any]:\n \"sub-agent is being force-stopped as soon as its in-flight turn completes, and \"\n \"none will send a completion report. Their confirmed vulnerabilities are \"\n \"already filed as they were found. Do not wait on any sub-agents and do not \"\n- \"spawn new ones — wrap up now and call finish_scan.\"\n+ f\"spawn new ones — wrap up now and call {finish_tool}.\"\n ),\n }\n \n@@ -1126,7 +1128,7 @@ async def _notify_root_on_budget_reserve(coordinator: AgentCoordinator) -> None:\n root = await coordinator.claim_reserve_notification()\n if root is None:\n return\n- await coordinator.send(root, _reserve_notice())\n+ await coordinator.send(root, _reserve_notice(coordinator.root_finish_tool))\n \n \n async def _notify_parent_on_exit(\ndiff --git a/strix/core/hooks.py b/strix/core/hooks.py\nindex eae4d7c..06650be 100644\n--- a/strix/core/hooks.py\n+++ b/strix/core/hooks.py\n@@ -104,16 +104,16 @@ _ROOT_DIRECTIVES: tuple[str, ...] = (\n (\n \"As the root agent, begin planning your wind-down of the whole scan: avoid \"\n \"starting large new lines of investigation, and keep your required objectives on \"\n- \"track so you can call finish_scan comfortably before the limit.\"\n+ \"track so you can call {finish_tool} comfortably before the limit.\"\n ),\n (\n \"As the root agent, prioritize wrapping up the whole scan now: stop opening new \"\n \"lines of investigation, close out only what is essential, and move toward calling \"\n- \"finish_scan to compile and deliver the final report.\"\n+ \"{finish_tool} to compile and deliver the final report.\"\n ),\n (\n \"As the root agent, STOP all other work on the whole scan and finish immediately: \"\n- \"secure your findings and call finish_scan now — anything left unfinished when the \"\n+ \"secure your findings and call {finish_tool} now — anything left unfinished when the \"\n \"limit is hit is discarded.\"\n ),\n )\n@@ -138,8 +138,11 @@ _SUBAGENT_DIRECTIVES: tuple[str, ...] = (\n \n def _wrapup_directive(context: RunContextWrapper[dict[str, Any]], stage: int) -> str:\n is_root = context.context.get(\"parent_id\") is None\n- directives = _ROOT_DIRECTIVES if is_root else _SUBAGENT_DIRECTIVES\n- return directives[stage]\n+ if not is_root:\n+ return _SUBAGENT_DIRECTIVES[stage]\n+ coordinator = coordinator_from_context(context.context)\n+ finish_tool = coordinator.root_finish_tool if coordinator is not None else \"finish_scan\"\n+ return _ROOT_DIRECTIVES[stage].format(finish_tool=finish_tool)\n \n \n def _urgency(stage: int) -> str:\ndiff --git a/strix/core/runner.py b/strix/core/runner.py\nindex 58124be..f9bb494 100644\n--- a/strix/core/runner.py\n+++ b/strix/core/runner.py\n@@ -49,6 +49,7 @@ from strix.report.state import get_global_report_state\n from strix.runtime import session_manager\n from strix.telemetry import set_scan_phase\n from strix.telemetry.logging import set_scan_id, setup_scan_logging\n+from strix.tools.finish.tool import finish_scan\n from strix.tools.output_store import (\n WORKSPACE_SPILL_DIR,\n configure_spill_writer,\n@@ -58,6 +59,7 @@ from strix.tools.output_store import (\n if TYPE_CHECKING:\n from agents.memory import SQLiteSession\n from agents.result import RunResultBase\n+ from agents.tool import Tool\n \n from strix.runtime.status import StatusSink\n from strix.tools.mcp import (\n@@ -215,6 +217,7 @@ async def run_strix_scan(\n status_sink: StatusSink | None = None,\n mcp_connection_requests: list[McpConnectionRequest] | None = None,\n mcp_status_sink: McpStatusSink | None = None,\n+ root_finish_tool: Tool = finish_scan,\n ) -> RunResultBase | None:\n \"\"\"Run or resume one Strix scan against a sandbox.\n \n@@ -237,6 +240,7 @@ async def run_strix_scan(\n command-line default) it reads ``~/.strix/mcp-servers.json`` itself. Either\n way the engine does the connecting, so the caller passes inert configs plus\n metadata and never live sessions.\n+ ``root_finish_tool`` is the tool the root agent ends the run with.\n \"\"\"\n \n def report(phase: str) -> None:\n@@ -293,6 +297,7 @@ async def run_strix_scan(\n coordinator = AgentCoordinator()\n coordinator.set_snapshot_path(agents_path)\n coordinator.set_budget_policy(budget_policy)\n+ coordinator.root_finish_tool = root_finish_tool.name\n \n from strix.tools.coverage.tools import hydrate_coverage_from_disk\n from strix.tools.notes.tools import hydrate_notes_from_disk\n@@ -503,6 +508,7 @@ async def run_strix_scan(\n system_prompt_context=root_context,\n instructions_override=root_instructions,\n supports_images=supports_images,\n+ finish_tool=root_finish_tool,\n )\n \n if not is_resume:\ndiff --git a/strix/tools/agents_graph/tools.py b/strix/tools/agents_graph/tools.py\nindex 60c8852..a26c1dc 100644\n--- a/strix/tools/agents_graph/tools.py\n+++ b/strix/tools/agents_graph/tools.py\n@@ -683,7 +683,8 @@ async def agent_finish(\n {\n \"success\": False,\n \"error\": (\n- \"agent_finish is for subagents. Root/main agents must call finish_scan instead\"\n+ \"agent_finish is for subagents. Root/main agents must call \"\n+ f\"{coordinator.root_finish_tool} instead\"\n ),\n },\n ensure_ascii=False,\ndiff --git a/tests/test_agent_tool_registration.py b/tests/test_agent_tool_registration.py\nindex 489fea7..e459670 100644\n--- a/tests/test_agent_tool_registration.py\n+++ b/tests/test_agent_tool_registration.py\n@@ -59,6 +59,15 @@ def test_registered_tools_appear_before_lifecycle_tool() -> None:\n assert child_names[-2:] == [\"extra\", \"agent_finish\"]\n \n \n+def test_root_ends_with_the_given_finish_tool() -> None:\n+ root = factory.build_strix_agent(is_root=True, finish_tool=_tool(\"finish_pr_review\"))\n+\n+ root_names = [t.name for t in root.tools]\n+\n+ assert root_names[-1] == \"finish_pr_review\"\n+ assert \"finish_scan\" not in root_names\n+\n+\n def test_per_call_extra_tools_stack_with_registry() -> None:\n factory.register_agent_tools(_tool(\"registered\"))\n \ndiff --git a/tests/test_execution.py b/tests/test_execution.py\nindex c3e1776..0daf0da 100644\n--- a/tests/test_execution.py\n+++ b/tests/test_execution.py\n@@ -132,6 +132,27 @@ async def test_reserve_stop_notifies_root_once(monkeypatch: pytest.MonkeyPatch)\n assert \"finish_scan\" in str(message[\"content\"])\n \n \n+@pytest.mark.asyncio\n+async def test_reserve_notice_names_the_root_finish_tool(monkeypatch: pytest.MonkeyPatch) -> None:\n+ coordinator = AgentCoordinator()\n+ coordinator.root_finish_tool = \"finish_pr_review\"\n+ await coordinator.register(\"root\", \"strix\", parent_id=None)\n+ await coordinator.register(\"child-a\", \"recon\", parent_id=\"root\")\n+\n+ sent: list[dict[str, Any]] = []\n+\n+ async def _record(_target_agent_id: str, message: dict[str, Any]) -> bool:\n+ sent.append(message)\n+ return True\n+\n+ monkeypatch.setattr(coordinator, \"send\", _record)\n+\n+ await _notify_root_on_budget_reserve(coordinator)\n+\n+ assert \"call finish_pr_review\" in str(sent[0][\"content\"])\n+ assert \"finish_scan\" not in str(sent[0][\"content\"])\n+\n+\n @pytest.mark.asyncio\n async def test_concurrent_reserve_claims_yield_single_root() -> None:\n coordinator = AgentCoordinator()\n@@ -1295,6 +1316,21 @@ async def test_interactive_nudge_offers_waiting_without_repeating() -> None:\n assert \"do not repeat it\" in items[0][\"content\"]\n \n \n+@pytest.mark.asyncio\n+async def test_nudge_names_the_root_finish_tool() -> None:\n+ items = await execution._append_tool_required_message(\n+ session=None,\n+ context={\"parent_id\": None},\n+ attempt=1,\n+ limit=3,\n+ interactive=False,\n+ root_finish_tool=\"finish_pr_review\",\n+ )\n+\n+ assert \"call finish_pr_review\" in items[0][\"content\"]\n+ assert \"finish_scan\" not in items[0][\"content\"]\n+\n+\n def _cycle_with_items(\n coordinator: AgentCoordinator,\n agent_id: str,\ndiff --git a/tests/test_hooks.py b/tests/test_hooks.py\nindex 16fce42..975a99b 100644\n--- a/tests/test_hooks.py\n+++ b/tests/test_hooks.py\n@@ -7,6 +7,7 @@ from unittest.mock import MagicMock, patch\n \n import pytest\n \n+from strix.core.agents import AgentCoordinator\n from strix.core.hooks import (\n BudgetExceededError,\n BudgetPausedError,\n@@ -335,6 +336,21 @@ async def test_budget_warning_root_directive_distinct_from_subagent() -> None:\n assert \"confirmed\" in sub\n \n \n+@pytest.mark.asyncio\n+async def test_root_directive_names_the_coordinators_finish_tool() -> None:\n+ hooks = ReportUsageHooks(model=\"test-model\", max_turns=100)\n+ coordinator = AgentCoordinator()\n+ coordinator.root_finish_tool = \"finish_pr_review\"\n+ ctx = _make_warn_context(requests=85, parent_id=None)\n+ ctx.context[\"coordinator\"] = coordinator\n+\n+ items: list[Any] = []\n+ await hooks.on_llm_start(ctx, MagicMock(), None, items)\n+\n+ assert \"finish_pr_review\" in items[0][\"content\"]\n+ assert \"finish_scan\" not in items[0][\"content\"]\n+\n+\n @pytest.mark.parametrize(\"parent_id\", [None, \"root-1\"])\n @pytest.mark.asyncio\n async def test_turn_warning_directive_escalates_per_stage(parent_id: str | None) -> None:\n", "patch_B2_upstream": "diff --git a/strix/agents/factory.py b/strix/agents/factory.py\nindex ca27e4f..f8a4124 100644\n--- a/strix/agents/factory.py\n+++ b/strix/agents/factory.py\n@@ -724,6 +724,7 @@ def build_strix_agent(\n instructions_override: str | None = None,\n supports_images: bool = True,\n finish_tool: Tool = finish_scan,\n+ report_tool: Tool = create_vulnerability_report,\n ) -> SandboxAgent[Any]:\n \"\"\"Build a SandboxAgent for either root or child use.\n \n@@ -737,6 +738,8 @@ def build_strix_agent(\n instructions_override: Use this verbatim as the system prompt instead\n of rendering the built-in scan prompt.\n finish_tool: The tool that ends the run, given to the root agent.\n+ report_tool: The tool every agent files findings with, in place of\n+ ``create_vulnerability_report``.\n \"\"\"\n if instructions_override is not None:\n instructions = instructions_override\n@@ -750,16 +753,18 @@ def build_strix_agent(\n interactive=interactive,\n system_prompt_context=system_prompt_context,\n supports_images=supports_images,\n+ report_tool=report_tool.name,\n )\n \n agent_tools = [*_EXTRA_TOOLS, *(extra_tools or [])]\n if interactive:\n # Yielding to the user is only meaningful when one is attached.\n agent_tools.append(wait_for_user)\n+ base_tools = [report_tool if t is create_vulnerability_report else t for t in _BASE_TOOLS]\n if is_root:\n- tools: list[Tool] = [*_BASE_TOOLS, *agent_tools, finish_tool]\n+ tools: list[Tool] = [*base_tools, *agent_tools, finish_tool]\n else:\n- tools = [*_BASE_TOOLS, *agent_tools, agent_finish]\n+ tools = [*base_tools, *agent_tools, agent_finish]\n _ensure_unique_tool_names(tools)\n tools = [\n _with_bounded_result(_with_strictness(_with_coerced_arguments(tool), strict_tool_schemas))\n@@ -812,6 +817,7 @@ def make_child_factory(\n strict_tool_schemas: bool = True,\n system_prompt_context: dict[str, Any] | None = None,\n supports_images: bool = True,\n+ report_tool: Tool = create_vulnerability_report,\n ) -> Any:\n \"\"\"Return the runner-owned builder used by ``spawn_child_agent``.\n \n@@ -833,6 +839,7 @@ def make_child_factory(\n strict_tool_schemas=strict_tool_schemas,\n system_prompt_context=system_prompt_context,\n supports_images=supports_images,\n+ report_tool=report_tool,\n )\n \n return _factory\ndiff --git a/strix/agents/prompt.py b/strix/agents/prompt.py\nindex c45831a..afbf56b 100644\n--- a/strix/agents/prompt.py\n+++ b/strix/agents/prompt.py\n@@ -86,6 +86,7 @@ def render_system_prompt(\n system_prompt_context: dict[str, Any] | None = None,\n include_scope: bool = True,\n supports_images: bool = True,\n+ report_tool: str = \"create_vulnerability_report\",\n ) -> str:\n \"\"\"Render the system prompt. Returns empty string on template failure.\n \n@@ -133,6 +134,7 @@ def render_system_prompt(\n is_root=is_root,\n system_prompt_context=system_prompt_context or {},\n include_scope=include_scope,\n+ report_tool=report_tool,\n **skill_content,\n )\n except Exception:\ndiff --git a/strix/agents/prompts/system_prompt.jinja b/strix/agents/prompts/system_prompt.jinja\nindex b13c9a4..b8300a1 100644\n--- a/strix/agents/prompts/system_prompt.jinja\n+++ b/strix/agents/prompts/system_prompt.jinja\n@@ -119,7 +119,7 @@ WHITE-BOX TESTING (code provided):\n - Local execution, unit/integration testing, patch verification, and HTTP requests against locally started in-scope services are normal authorized white-box validation\n - If dynamically running the code proves impossible after exhaustive attempts, pivot to comprehensive static analysis.\n - Try to infer how to run the code based on its structure and content.\n-- Derive the code fix as PART OF reporting, not as a separate later pass: create_vulnerability_report already requires the concrete patch inline (`code_locations` with verbatim `fix_before`/`fix_after` and `fix_pr_body`), so the reporting agent that analyzes the root cause is the one that produces the fix. Do NOT spawn a downstream agent afterwards to re-derive/re-apply the same patch.\n+- Derive the code fix as PART OF reporting, not as a separate later pass: {{ report_tool }} already requires the concrete patch inline (`code_locations` with verbatim `fix_before`/`fix_after` and `fix_pr_body`), so the reporting agent that analyzes the root cause is the one that produces the fix. Do NOT spawn a downstream agent afterwards to re-derive/re-apply the same patch.\n - If you also apply and verify the patch in the repo (edit the file, re-test that the vulnerability is gone), do it in the same agent/turn while the analysis is fresh — right before or as part of filing the report — never as a second re-analysis pass.\n \n COMBINED MODE (code + deployed target present):\n@@ -205,9 +205,9 @@ VALIDATION REQUIREMENTS:\n - COVERAGE: record every surface you assess with `record_coverage` (surface + risk area + outcome + evidence), including the ones that came back clean — a report that only lists findings cannot say what was reviewed and cleared. Use the `needs_follow_up` outcome for anything left in an `open_proof_gap` state, and carry the same items up in `agent_finish(open_items=[...])`. The ledger is shared and mutable: when you resolve a surface another agent left open — or find that a closed one is not — move that entry with `update_coverage` instead of recording a second one for the same surface. The root agent reconciles all of it via `list_coverage` before `finish_scan`.\n - THREAT MODEL: before you start testing, call `get_threat_model` on the target you were pointed at — it is the scan's shared answer to who the attacker is, where the trust boundaries sit, and what counts as critical here. It is scoped to this scan and nothing carries over from an earlier run, so `found: false` means no agent on this run has derived one yet. Read it instead of re-deriving trust boundaries yourself; where your testing disproves it — a boundary it calls trusted turns out to be attacker-reachable, a role it did not know about, a host or endpoint it never listed — record that with `amend_threat_model` so the agents after you inherit the correction. Amending is not optional politeness: a model nobody corrects turns the first agent's guesses into everyone's assumptions.\n - Before filing any report, run the counterevidence pass: argue the strongest case AGAINST the finding, record what you found in the `counterevidence` field, set `confidence` honestly (a static-only trace you couldn't execute is at best `medium`), and state what evidence would change the severity. See the counterevidence and severity-calibration knowledge above.\n-- A vulnerability is ONLY considered reported when a reporting agent uses create_vulnerability_report (or create_dependency_report for known-CVE dependency/supply-chain findings) with full details. Mentions in agent_finish, finish_scan, or generic messages are NOT sufficient\n-- Reporting and fixing are ONE step, not two: when source is available, the reporting agent derives the concrete fix and files it INLINE via create_vulnerability_report (`code_locations` with `fix_before`/`fix_after` + `fix_pr_body`) — the report is not complete without it. Do NOT report first and then spawn a separate downstream agent to re-derive and re-apply the same patch; that just re-does the analysis and wastes tokens. (Do not silently patch a finding WITHOUT filing a report — the report, with its embedded fix, is the deliverable.)\n-- DEDUPLICATION: The create_vulnerability_report tool uses LLM-based deduplication. If it rejects your report as a duplicate, DO NOT attempt to re-submit the same vulnerability. Accept the rejection and move on to testing other areas. The vulnerability has already been reported by another agent. If your evidence proves more than the finding it matched (a working exploit where that one had only a static trace, a chain that raises the impact), revise that finding with update_vulnerability_report using the duplicate_of id — never re-file it.\n+- A vulnerability is ONLY considered reported when a reporting agent uses {{ report_tool }} (or create_dependency_report for known-CVE dependency/supply-chain findings) with full details. Mentions in agent_finish, finish_scan, or generic messages are NOT sufficient\n+- Reporting and fixing are ONE step, not two: when source is available, the reporting agent derives the concrete fix and files it INLINE via {{ report_tool }} (`code_locations` with `fix_before`/`fix_after` + `fix_pr_body`) — the report is not complete without it. Do NOT report first and then spawn a separate downstream agent to re-derive and re-apply the same patch; that just re-does the analysis and wastes tokens. (Do not silently patch a finding WITHOUT filing a report — the report, with its embedded fix, is the deliverable.)\n+- DEDUPLICATION: The {{ report_tool }} tool uses LLM-based deduplication. If it rejects your report as a duplicate, DO NOT attempt to re-submit the same vulnerability. Accept the rejection and move on to testing other areas. The vulnerability has already been reported by another agent. If your evidence proves more than the finding it matched (a working exploit where that one had only a static trace, a chain that raises the impact), revise that finding with update_vulnerability_report using the duplicate_of id — never re-file it.\n - HTTP EVIDENCE: a finding you validated through the proxy is not fully filed until `http_exchange_ids` carries the proxy request ids of the exchanges that prove it — the request that triggers the vulnerability plus the baseline/control request it differs from (an unauthenticated success next to the authenticated one, the payload response next to the benign one). Copy the ids exactly as `list_requests`/`view_request` show them, never invent or guess one, and never omit the field to bypass validation. Leave it out only when there is no captured HTTP exchange at all (static-only code findings, dependency CVEs). If you filed before the proving exchanges existed, attach them afterwards with update_vulnerability_report. Without the ids, the finding ships as prose nobody can replay.\n - REVISING A FINDING: use update_vulnerability_report (report id + the fields you want to replace + update_reason) when you learn something a finding already on file does not carry — you built the PoC after filing it, a chain raised its impact, further testing weakened it, or its counterevidence/remediation/code locations were wrong. Editing a finding needs no duplicate verdict, and it is always better than filing a second report for the same issue. Read the finding first with get_report, and pass only the fields that change.\n - WITHDRAWING A FINDING: when re-testing proves a finding you filed is not a vulnerability at all — the exploit only worked because of your own test setup (a mixed-up session, a self-inflicted state change, a misread response), the behaviour is intended, or the control is in fact enforced — delete it with delete_vulnerability_report (report id + delete_reason). Never leave a disproved finding on file as a zero-CVSS, \"retracted\", or \"false positive\" report, and never rewrite its text into a note saying it was wrong: a report that exists is read as a finding. Delete is for a finding that does not exist; a finding that is real but weaker than filed is revised, not deleted.\n@@ -227,7 +227,7 @@ Every one of these tools writes to state the rest of the scan reads. Reaching fo\n - STEER CHILDREN — `send_message_to_agent`: send a running child new information, a course correction, or a request to wrap up, without killing it. Use it to answer a child's question or narrow its scope mid-run.\n - BLOCK ON CHILDREN — `wait_for_agents`: block until named children report back when your next move genuinely depends on their results. If you can keep making progress in parallel, keep working instead of waiting.\n - CANCEL CHILDREN — `stop_agent`: gracefully cancel a child whose work is redundant, misdirected, or no longer needed. Prefer `send_message_to_agent` to redirect a child that is merely off-track; reserve `stop_agent` for work that should not continue at all.\n-- FINISH — subagents call `agent_finish` (with `open_items=[...]` for anything left unresolved); the root agent calls `finish_scan` exactly once, only after every child is wrapped up and coverage is reconciled. `agent_finish`/`finish_scan` are handoffs, not reporting channels — a vulnerability is reported only via `create_vulnerability_report`/`create_dependency_report`.\n+- FINISH — subagents call `agent_finish` (with `open_items=[...]` for anything left unresolved); the root agent calls `finish_scan` exactly once, only after every child is wrapped up and coverage is reconciled. `agent_finish`/`finish_scan` are handoffs, not reporting channels — a vulnerability is reported only via `{{ report_tool }}`/`create_dependency_report`.\n </execution_guidelines>\n \n <vulnerability_focus>\n@@ -380,7 +380,7 @@ CRITICAL RULES:\n - **REALISTIC OUTCOMES** - Some tests find nothing, some validations fail\n - **ONE AGENT = ONE TASK** - Don't let agents do multiple unrelated jobs\n - **SPAWN REACTIVELY** - Create new agents based on what you discover\n-- **ONLY REPORTING AGENTS** can use create_vulnerability_report tool\n+- **ONLY REPORTING AGENTS** can use {{ report_tool }} tool\n - **AGENT SPECIALIZATION MANDATORY** - Each agent must be highly specialized; prefer 1–3 skills, up to 5 for complex contexts\n - **NO GENERIC AGENTS** - Avoid creating broad, multi-purpose agents that dilute focus\n \ndiff --git a/strix/core/runner.py b/strix/core/runner.py\nindex ae6dc08..f2482b7 100644\n--- a/strix/core/runner.py\n+++ b/strix/core/runner.py\n@@ -54,6 +54,7 @@ from strix.tools.output_store import (\n WORKSPACE_SPILL_DIR,\n configure_spill_writer,\n )\n+from strix.tools.reporting.tool import create_vulnerability_report\n \n \n if TYPE_CHECKING:\n@@ -172,6 +173,7 @@ def _compose_root_instructions_override(\n interactive: bool,\n system_prompt_context: dict[str, Any],\n supports_images: bool,\n+ report_tool: str,\n ) -> str | None:\n if root_instructions_override is None:\n return None\n@@ -186,6 +188,7 @@ def _compose_root_instructions_override(\n system_prompt_context=system_prompt_context,\n include_scope=False,\n supports_images=supports_images,\n+ report_tool=report_tool,\n )\n return (\n f\"{base_instructions}\\n\\n\"\n@@ -218,6 +221,7 @@ async def run_strix_scan(\n mcp_connection_requests: list[McpConnectionRequest] | None = None,\n mcp_status_sink: McpStatusSink | None = None,\n root_finish_tool: Tool = finish_scan,\n+ report_tool: Tool = create_vulnerability_report,\n ) -> RunResultBase | None:\n \"\"\"Run or resume one Strix scan against a sandbox.\n \n@@ -241,6 +245,8 @@ async def run_strix_scan(\n way the engine does the connecting, so the caller passes inert configs plus\n metadata and never live sessions.\n ``root_finish_tool`` is the tool the root agent ends the run with.\n+ ``report_tool`` is the tool every agent files findings with, in place of\n+ ``create_vulnerability_report``.\n \"\"\"\n \n def report(phase: str) -> None:\n@@ -495,6 +501,7 @@ async def run_strix_scan(\n interactive=interactive,\n system_prompt_context=root_context,\n supports_images=supports_images,\n+ report_tool=report_tool.name,\n )\n \n root_agent = build_strix_agent(\n@@ -511,6 +518,7 @@ async def run_strix_scan(\n instructions_override=root_instructions,\n supports_images=supports_images,\n finish_tool=root_finish_tool,\n+ report_tool=report_tool,\n )\n \n if not is_resume:\n@@ -531,6 +539,7 @@ async def run_strix_scan(\n strict_tool_schemas=strict_tool_schemas,\n system_prompt_context=scope_context,\n supports_images=supports_images,\n+ report_tool=report_tool,\n )\n \n async def spawn_child_agent(**kwargs: Any) -> dict[str, Any]:\ndiff --git a/strix/skills/analysis/counterevidence.md b/strix/skills/analysis/counterevidence.md\nindex fd90a25..0f40aae 100644\n--- a/strix/skills/analysis/counterevidence.md\n+++ b/strix/skills/analysis/counterevidence.md\n@@ -20,7 +20,7 @@ state, and \"I moved on\" is not one of them.\n \n **1. `confirmed`** — you have a working PoC or, in white-box, a complete\n source → control → sink → impact trace plus evidence the path is\n-reachable. File it with `create_vulnerability_report`.\n+reachable. File it as a vulnerability report.\n \n **2. `ruled_out`** — you can name the **specific control** that makes the\n code safe, at a specific location, and you have checked that the control\n@@ -144,8 +144,7 @@ endpoint is broken/unreachable for unrelated reasons\".\n \n ## Before You File a Report\n \n-Run this pass on every finding before calling\n-`create_vulnerability_report`:\n+Run this pass on every finding before filing it:\n \n 1. **Argue the other side.** Spend real effort building the strongest\n case that this is *not* exploitable, or not as severe as you think.\ndiff --git a/tests/test_agent_tool_registration.py b/tests/test_agent_tool_registration.py\nindex e459670..9af8886 100644\n--- a/tests/test_agent_tool_registration.py\n+++ b/tests/test_agent_tool_registration.py\n@@ -93,6 +93,17 @@ def test_per_call_extra_tools_reject_duplicate_registered_names() -> None:\n factory.build_strix_agent(is_root=True, extra_tools=[_tool(\"same_name\")])\n \n \n+def test_report_tool_replaces_create_vulnerability_report() -> None:\n+ for is_root in (True, False):\n+ agent = factory.build_strix_agent(is_root=is_root, report_tool=_tool(\"file_pr_finding\"))\n+ names = [t.name for t in agent.tools]\n+ assert \"file_pr_finding\" in names\n+ assert \"create_vulnerability_report\" not in names\n+ assert isinstance(agent.instructions, str)\n+ assert \"file_pr_finding\" in agent.instructions\n+ assert \"create_vulnerability_report\" not in agent.instructions\n+\n+\n def test_instructions_override_is_used_verbatim() -> None:\n custom = \"You are a scan agent. Follow the provided scope.\"\n \n", "tests_A": [{"path": "tests/test_agent_tool_registration.py", "content": "\"\"\"Tests for scan-agent tool registration in factory.\"\"\"\n\nfrom __future__ import annotations\n\nimport pytest\nfrom agents.tool import FunctionTool\n\nfrom strix.agents import factory\n\n\ndef _tool(name: str) -> FunctionTool:\n return FunctionTool(\n name=name,\n description=\"test tool\",\n params_json_schema={\"type\": \"object\", \"properties\": {}, \"additionalProperties\": False},\n on_invoke_tool=lambda _ctx, _inp: \"ok\",\n )\n\n\n@pytest.fixture(autouse=True)\ndef _reset_registry() -> object:\n saved = list(factory._EXTRA_TOOLS)\n factory._EXTRA_TOOLS.clear()\n try:\n yield\n finally:\n factory._EXTRA_TOOLS[:] = saved\n\n\ndef test_register_agent_tools_is_deduped() -> None:\n tool = _tool(\"dup\")\n factory.register_agent_tools(tool)\n factory.register_agent_tools(tool)\n assert factory.registered_agent_tools() == (tool,)\n\n\ndef test_registered_tools_appear_before_lifecycle_tool() -> None:\n tool = _tool(\"extra\")\n factory.register_agent_tools(tool)\n\n root = factory.build_strix_agent(is_root=True)\n child = factory.build_strix_agent(is_root=False)\n\n root_names = [t.name for t in root.tools]\n child_names = [t.name for t in child.tools]\n\n assert root_names[-2:] == [\"extra\", \"finish_scan\"]\n assert child_names[-2:] == [\"extra\", \"agent_finish\"]\n\n\ndef test_per_call_extra_tools_stack_with_registry() -> None:\n factory.register_agent_tools(_tool(\"registered\"))\n\n agent = factory.build_strix_agent(is_root=True, extra_tools=[_tool(\"per_call\")])\n names = [t.name for t in agent.tools]\n\n assert \"registered\" in names\n assert \"per_call\" in names\n assert names[-1] == \"finish_scan\"\n\n\ndef test_register_agent_tools_rejects_duplicate_names() -> None:\n factory.register_agent_tools(_tool(\"same_name\"))\n\n with pytest.raises(ValueError, match=\"same_name\"):\n factory.register_agent_tools(_tool(\"same_name\"))\n\n\ndef test_per_call_extra_tools_reject_duplicate_registered_names() -> None:\n factory.register_agent_tools(_tool(\"same_name\"))\n\n with pytest.raises(ValueError, match=\"same_name\"):\n factory.build_strix_agent(is_root=True, extra_tools=[_tool(\"same_name\")])\n\n\ndef test_instructions_override_is_used_verbatim() -> None:\n custom = \"You are a scan agent. Follow the provided scope.\"\n\n agent = factory.build_strix_agent(is_root=True, instructions_override=custom)\n\n assert agent.instructions == custom\n\n\ndef test_no_override_renders_builtin_prompt() -> None:\n agent = factory.build_strix_agent(is_root=True)\n\n assert isinstance(agent.instructions, str)\n assert agent.instructions != \"\"\n"}], "tests_B1": [{"path": "tests/test_agent_tool_registration.py", "content": "\"\"\"Tests for scan-agent tool registration in factory.\"\"\"\n\nfrom __future__ import annotations\n\nimport pytest\nfrom agents.tool import FunctionTool\n\nfrom strix.agents import factory\n\n\ndef _tool(name: str) -> FunctionTool:\n return FunctionTool(\n name=name,\n description=\"test tool\",\n params_json_schema={\"type\": \"object\", \"properties\": {}, \"additionalProperties\": False},\n on_invoke_tool=lambda _ctx, _inp: \"ok\",\n )\n\n\n@pytest.fixture(autouse=True)\ndef _reset_registry() -> object:\n saved = list(factory._EXTRA_TOOLS)\n factory._EXTRA_TOOLS.clear()\n try:\n yield\n finally:\n factory._EXTRA_TOOLS[:] = saved\n\n\ndef test_register_agent_tools_is_deduped() -> None:\n tool = _tool(\"dup\")\n factory.register_agent_tools(tool)\n factory.register_agent_tools(tool)\n assert factory.registered_agent_tools() == (tool,)\n\n\ndef test_registered_tools_appear_before_lifecycle_tool() -> None:\n tool = _tool(\"extra\")\n factory.register_agent_tools(tool)\n\n root = factory.build_strix_agent(is_root=True)\n child = factory.build_strix_agent(is_root=False)\n\n root_names = [t.name for t in root.tools]\n child_names = [t.name for t in child.tools]\n\n assert root_names[-2:] == [\"extra\", \"finish_scan\"]\n assert child_names[-2:] == [\"extra\", \"agent_finish\"]\n\n\ndef test_root_ends_with_the_given_finish_tool() -> None:\n root = factory.build_strix_agent(is_root=True, finish_tool=_tool(\"finish_pr_review\"))\n\n root_names = [t.name for t in root.tools]\n\n assert root_names[-1] == \"finish_pr_review\"\n assert \"finish_scan\" not in root_names\n\n\ndef test_per_call_extra_tools_stack_with_registry() -> None:\n factory.register_agent_tools(_tool(\"registered\"))\n\n agent = factory.build_strix_agent(is_root=True, extra_tools=[_tool(\"per_call\")])\n names = [t.name for t in agent.tools]\n\n assert \"registered\" in names\n assert \"per_call\" in names\n assert names[-1] == \"finish_scan\"\n\n\ndef test_register_agent_tools_rejects_duplicate_names() -> None:\n factory.register_agent_tools(_tool(\"same_name\"))\n\n with pytest.raises(ValueError, match=\"same_name\"):\n factory.register_agent_tools(_tool(\"same_name\"))\n\n\ndef test_per_call_extra_tools_reject_duplicate_registered_names() -> None:\n factory.register_agent_tools(_tool(\"same_name\"))\n\n with pytest.raises(ValueError, match=\"same_name\"):\n factory.build_strix_agent(is_root=True, extra_tools=[_tool(\"same_name\")])\n\n\ndef test_instructions_override_is_used_verbatim() -> None:\n custom = \"You are a scan agent. Follow the provided scope.\"\n\n agent = factory.build_strix_agent(is_root=True, instructions_override=custom)\n\n assert agent.instructions == custom\n\n\ndef test_no_override_renders_builtin_prompt() -> None:\n agent = factory.build_strix_agent(is_root=True)\n\n assert isinstance(agent.instructions, str)\n assert agent.instructions != \"\"\n"}, {"path": "tests/test_execution.py", "content": "\"\"\"Tests for the scan-wide budget-stop signal on the agent coordinator.\"\"\"\n\nfrom __future__ import annotations\n\nimport asyncio\n\nimport pytest\n\nfrom strix.core.agents import AgentCoordinator\n\n\n@pytest.mark.asyncio\nasync def test_budget_stop_sets_flag() -> None:\n coordinator = AgentCoordinator()\n await coordinator.register(\"root\", \"strix\", parent_id=None)\n\n assert coordinator.budget_stopped is False\n await coordinator.trigger_budget_stop()\n assert coordinator.budget_stopped is True\n\n\n@pytest.mark.asyncio\nasync def test_budget_stop_unblocks_parked_agent() -> None:\n # A parent parked in wait_for_message (awaiting a child) must be released so\n # it can exit, no matter where in the tree the budget limit was hit.\n coordinator = AgentCoordinator()\n await coordinator.register(\"parent\", \"strix\", parent_id=None)\n\n waiter = asyncio.create_task(coordinator.wait_for_message(\"parent\"))\n await asyncio.sleep(0) # let the waiter park\n assert not waiter.done()\n\n await coordinator.trigger_budget_stop()\n await asyncio.wait_for(waiter, timeout=1.0)\n\n\n@pytest.mark.asyncio\nasync def test_wait_for_message_returns_immediately_after_budget_stop() -> None:\n coordinator = AgentCoordinator()\n await coordinator.register(\"agent\", \"recon\", parent_id=\"parent\")\n await coordinator.trigger_budget_stop()\n\n # No pending messages, but the stop flag short-circuits the wait.\n await asyncio.wait_for(coordinator.wait_for_message(\"agent\"), timeout=1.0)\n\n\n@pytest.mark.asyncio\nasync def test_nudge_names_the_root_finish_tool() -> None:\n from strix.core.execution import _append_noninteractive_tool_required_message\n\n items = await _append_noninteractive_tool_required_message(\n session=None,\n context={\"parent_id\": None},\n attempt=1,\n limit=3,\n root_finish_tool=\"finish_pr_review\",\n )\n\n assert \"call finish_pr_review\" in items[0][\"content\"]\n assert \"finish_scan\" not in items[0][\"content\"]\n"}], "tests_B2": [{"path": "tests/test_agent_tool_registration.py", "content": "\"\"\"Tests for scan-agent tool registration in factory.\"\"\"\n\nfrom __future__ import annotations\n\nimport pytest\nfrom agents.tool import FunctionTool\n\nfrom strix.agents import factory\n\n\ndef _tool(name: str) -> FunctionTool:\n return FunctionTool(\n name=name,\n description=\"test tool\",\n params_json_schema={\"type\": \"object\", \"properties\": {}, \"additionalProperties\": False},\n on_invoke_tool=lambda _ctx, _inp: \"ok\",\n )\n\n\n@pytest.fixture(autouse=True)\ndef _reset_registry() -> object:\n saved = list(factory._EXTRA_TOOLS)\n factory._EXTRA_TOOLS.clear()\n try:\n yield\n finally:\n factory._EXTRA_TOOLS[:] = saved\n\n\ndef test_register_agent_tools_is_deduped() -> None:\n tool = _tool(\"dup\")\n factory.register_agent_tools(tool)\n factory.register_agent_tools(tool)\n assert factory.registered_agent_tools() == (tool,)\n\n\ndef test_registered_tools_appear_before_lifecycle_tool() -> None:\n tool = _tool(\"extra\")\n factory.register_agent_tools(tool)\n\n root = factory.build_strix_agent(is_root=True)\n child = factory.build_strix_agent(is_root=False)\n\n root_names = [t.name for t in root.tools]\n child_names = [t.name for t in child.tools]\n\n assert root_names[-2:] == [\"extra\", \"finish_scan\"]\n assert child_names[-2:] == [\"extra\", \"agent_finish\"]\n\n\ndef test_per_call_extra_tools_stack_with_registry() -> None:\n factory.register_agent_tools(_tool(\"registered\"))\n\n agent = factory.build_strix_agent(is_root=True, extra_tools=[_tool(\"per_call\")])\n names = [t.name for t in agent.tools]\n\n assert \"registered\" in names\n assert \"per_call\" in names\n assert names[-1] == \"finish_scan\"\n\n\ndef test_register_agent_tools_rejects_duplicate_names() -> None:\n factory.register_agent_tools(_tool(\"same_name\"))\n\n with pytest.raises(ValueError, match=\"same_name\"):\n factory.register_agent_tools(_tool(\"same_name\"))\n\n\ndef test_per_call_extra_tools_reject_duplicate_registered_names() -> None:\n factory.register_agent_tools(_tool(\"same_name\"))\n\n with pytest.raises(ValueError, match=\"same_name\"):\n factory.build_strix_agent(is_root=True, extra_tools=[_tool(\"same_name\")])\n\n\ndef test_report_tool_replaces_create_vulnerability_report() -> None:\n for is_root in (True, False):\n agent = factory.build_strix_agent(is_root=is_root, report_tool=_tool(\"file_pr_finding\"))\n names = [t.name for t in agent.tools]\n assert \"file_pr_finding\" in names\n assert \"create_vulnerability_report\" not in names\n assert isinstance(agent.instructions, str)\n assert \"file_pr_finding\" in agent.instructions\n assert \"create_vulnerability_report\" not in agent.instructions\n\n\ndef test_instructions_override_is_used_verbatim() -> None:\n custom = \"You are a scan agent. Follow the provided scope.\"\n\n agent = factory.build_strix_agent(is_root=True, instructions_override=custom)\n\n assert agent.instructions == custom\n\n\ndef test_no_override_renders_builtin_prompt() -> None:\n agent = factory.build_strix_agent(is_root=True)\n\n assert isinstance(agent.instructions, str)\n assert agent.instructions != \"\"\n"}], "fail_to_pass_A": ["tests/test_agent_tool_registration.py::test_instructions_override_is_used_verbatim", "tests/test_agent_tool_registration.py::test_no_override_renders_builtin_prompt", "tests/test_agent_tool_registration.py::test_per_call_extra_tools_reject_duplicate_registered_names", "tests/test_agent_tool_registration.py::test_per_call_extra_tools_stack_with_registry", "tests/test_agent_tool_registration.py::test_register_agent_tools_is_deduped", "tests/test_agent_tool_registration.py::test_register_agent_tools_rejects_duplicate_names", "tests/test_agent_tool_registration.py::test_registered_tools_appear_before_lifecycle_tool"], "fail_to_pass_B1": ["tests/test_agent_tool_registration.py::test_root_ends_with_the_given_finish_tool", "tests/test_execution.py::test_nudge_names_the_root_finish_tool"], "fail_to_pass_B2": ["tests/test_agent_tool_registration.py::test_report_tool_replaces_create_vulnerability_report"], "pass_to_pass": ["tests/test_cli_target_list.py::test_parse_arguments_accepts_target_list_file", "tests/test_cli_target_list.py::test_parse_arguments_combines_target_and_target_list", "tests/test_cli_target_list.py::test_parse_arguments_rejects_resume_with_target_list", "tests/test_config_loader.py::test_aliases_for_alias_choices", "tests/test_config_loader.py::test_aliases_for_no_alias", "tests/test_config_loader.py::test_aliases_for_simple_alias", "tests/test_config_loader.py::test_aliases_for_string_validation_alias", "tests/test_config_loader.py::test_apply_config_override_invalidates_cache", "tests/test_config_loader.py::test_apply_override_and_load_settings_round_trip", "tests/test_config_loader.py::test_persist_current_sets_0600_mode", "tests/test_config_loader.py::test_persist_current_writes_env_block", "tests/test_config_loader.py::test_read_json_overrides_corrupt_json", "tests/test_config_loader.py::test_read_json_overrides_env_wins_across_field_aliases", "tests/test_config_loader.py::test_read_json_overrides_env_wins_case_insensitively", "tests/test_config_loader.py::test_read_json_overrides_maps_to_nested_settings", "tests/test_config_loader.py::test_read_json_overrides_missing_file", "tests/test_config_loader.py::test_read_json_overrides_non_dict_env", "tests/test_config_loader.py::test_read_json_overrides_skips_keys_already_in_environ", "tests/test_config_loader.py::test_read_json_overrides_uses_json_when_no_alias_in_environ", "tests/test_cost_tracking.py::test_cost_callback_reads_openrouter_stream_usage_cost", "tests/test_cost_tracking.py::test_cost_callback_reads_usage_cost_from_mapping_response", "tests/test_cost_tracking.py::test_streaming_logging_stays_enabled_for_cost_callback", "tests/test_docker_client_delete.py::test_delete_does_not_swallow_unrelated_errors", "tests/test_docker_client_delete.py::test_delete_noop_without_container_id", "tests/test_docker_client_delete.py::test_delete_swallows_best_effort_kill_errors[exc0]", "tests/test_docker_client_delete.py::test_delete_swallows_best_effort_kill_errors[exc1]", "tests/test_docker_client_delete.py::test_delete_swallows_best_effort_kill_errors[exc2]", "tests/test_execution.py::test_budget_stop_sets_flag", "tests/test_execution.py::test_budget_stop_unblocks_parked_agent", "tests/test_execution.py::test_wait_for_message_returns_immediately_after_budget_stop", "tests/test_hooks.py::test_at_budget_raises", "tests/test_hooks.py::test_budget_check_uses_live_cost_accessor", "tests/test_hooks.py::test_budget_exceeded_error_is_runtime_error", "tests/test_hooks.py::test_error_message_includes_amounts", "tests/test_hooks.py::test_no_budget_never_raises", "tests/test_hooks.py::test_no_raise_when_report_state_none", "tests/test_hooks.py::test_non_positive_budget_rejected[-0.01]", "tests/test_hooks.py::test_non_positive_budget_rejected[-5.0]", "tests/test_hooks.py::test_non_positive_budget_rejected[0.0]", "tests/test_hooks.py::test_over_budget_raises", "tests/test_hooks.py::test_under_budget_does_not_raise", "tests/test_inputs.py::test_build_root_task_diff_scope", "tests/test_inputs.py::test_build_root_task_empty_config", "tests/test_inputs.py::test_build_root_task_repository_target", "tests/test_inputs.py::test_build_root_task_web_application_with_instructions", "tests/test_inputs.py::test_child_initial_input_no_consecutive_same_role[parent_history0]", "tests/test_inputs.py::test_child_initial_input_no_consecutive_same_role[parent_history1]", "tests/test_inputs.py::test_child_initial_input_single_message_with_history", "tests/test_inputs.py::test_child_initial_input_single_message_without_history", "tests/test_inputs.py::test_make_model_settings_forces_required_for_anyllm_routed_openai_model", "tests/test_inputs.py::test_make_model_settings_forces_required_for_routed_openai_model", "tests/test_inputs.py::test_make_model_settings_forces_required_tool_choice_for_openai_models[gpt-4o]", "tests/test_inputs.py::test_make_model_settings_forces_required_tool_choice_for_openai_models[openai/o3]", "tests/test_inputs.py::test_make_model_settings_skips_required_tool_choice_for_non_openai_models", "tests/test_local_sources.py::test_build_mount_targets_info_for_valid_dir", "tests/test_local_sources.py::test_build_mount_targets_info_rejects_empty_path[ ]", "tests/test_local_sources.py::test_build_mount_targets_info_rejects_empty_path[]", "tests/test_local_sources.py::test_build_mount_targets_info_rejects_file", "tests/test_local_sources.py::test_build_mount_targets_info_rejects_missing_path", "tests/test_local_sources.py::test_collect_local_sources_propagates_mount_flag", "tests/test_local_sources.py::test_collect_local_sources_repository_is_never_mounted", "tests/test_local_sources.py::test_dedupe_collapses_duplicate_mounts", "tests/test_local_sources.py::test_dedupe_keeps_distinct_targets_in_order", "tests/test_local_sources.py::test_dedupe_mount_supersedes_copied_same_path", "tests/test_local_sources.py::test_directory_size_empty_dir_is_zero", "tests/test_local_sources.py::test_directory_size_logs_and_skips_unreadable_subdir", "tests/test_local_sources.py::test_directory_size_skips_symlinks", "tests/test_local_sources.py::test_directory_size_sums_flat_and_nested_files", "tests/test_local_sources.py::test_find_oversized_disabled_for_non_positive_limit[-1]", "tests/test_local_sources.py::test_find_oversized_disabled_for_non_positive_limit[0]", "tests/test_local_sources.py::test_find_oversized_ignores_mounted_targets", "tests/test_local_sources.py::test_find_oversized_ignores_non_local_targets", "tests/test_local_sources.py::test_find_oversized_returns_nothing_under_limit", "tests/test_local_sources.py::test_find_oversized_returns_target_over_limit", "tests/test_local_sources.py::test_read_target_list_file_ignores_comment_lines", "tests/test_local_sources.py::test_read_target_list_file_rejects_empty_file", "tests/test_local_sources.py::test_read_target_list_file_rejects_empty_path[ ]", "tests/test_local_sources.py::test_read_target_list_file_rejects_empty_path[]", "tests/test_local_sources.py::test_read_target_list_file_rejects_missing_path", "tests/test_local_sources.py::test_read_target_list_file_rejects_non_utf8_file", "tests/test_local_sources.py::test_read_target_list_file_strips_blank_lines", "tests/test_notes.py::test_create_note_retries_on_note_id_collision", "tests/test_notes.py::test_create_note_returns_error_after_repeated_note_id_collisions", "tests/test_optional_deps.py::test_bedrock_extra_pins_boto3", "tests/test_optional_deps.py::test_vertex_extra_pins_google_auth", "tests/test_provider_hints.py::test_bedrock_boto3_hint", "tests/test_provider_hints.py::test_bedrock_boto3_hint_for_litellm_wrapped_connection_error", "tests/test_provider_hints.py::test_non_import_error_returns_none", "tests/test_provider_hints.py::test_unrelated_provider_returns_none", "tests/test_provider_hints.py::test_vertex_google_hint", "tests/test_provider_hints.py::test_vertex_google_hint_for_deeply_chained_error", "tests/test_provider_hints.py::test_vertex_google_hint_for_litellm_wrapped_connection_error", "tests/test_provider_hints.py::test_vertex_google_submodule_hint", "tests/test_proxy_renderer.py::test_more_content_hint_shown_when_has_more_flag_set", "tests/test_proxy_renderer.py::test_more_content_hint_shown_when_over_fifteen_lines", "tests/test_proxy_renderer.py::test_no_more_content_hint_within_fifteen_lines", "tests/test_report_writer.py::test_read_run_record_corrupt_raises", "tests/test_report_writer.py::test_read_run_record_missing_returns_empty", "tests/test_report_writer.py::test_read_run_record_non_object_raises", "tests/test_report_writer.py::test_render_vulnerability_md_includes_core_sections", "tests/test_report_writer.py::test_write_and_read_run_record_round_trip", "tests/test_report_writer.py::test_write_executive_report_writes_markdown", "tests/test_report_writer.py::test_write_vulnerabilities_creates_markdown_csv_and_json", "tests/test_report_writer.py::test_write_vulnerabilities_skips_already_saved_ids", "tests/test_runner_rate_limit.py::test_persistent_rate_limit_stops_gracefully", "tests/test_sarif.py::test_write_sarif_adds_logical_location_for_endpoint", "tests/test_sarif.py::test_write_sarif_always_emits_for_zero_findings", "tests/test_sarif.py::test_write_sarif_basic_shape", "tests/test_sarif.py::test_write_sarif_builds_fixes_from_code_location_fix_pairs", "tests/test_sarif.py::test_write_sarif_distinct_findings_get_distinct_fingerprints", "tests/test_sarif.py::test_write_sarif_emits_version_control_provenance", "tests/test_sarif.py::test_write_sarif_fingerprint_stable_across_title_rewording", "tests/test_sarif.py::test_write_sarif_locationless_finding_is_anchored_not_dropped", "tests/test_sarif.py::test_write_sarif_never_embeds_poc_script", "tests/test_sarif.py::test_write_sarif_omits_fixes_without_fix_pairs", "tests/test_sarif.py::test_write_sarif_omits_provenance_when_no_repository_context", "tests/test_sarif.py::test_write_sarif_replaces_atomically_no_partial_on_reemit", "tests/test_sarif.py::test_write_sarif_synthetic_finding_falls_back_to_resource_logical_location", "tests/test_sarif.py::test_write_sarif_tool_version_is_reported", "tests/test_sarif_stride.py::test_every_leg_letter_is_valid", "tests/test_sarif_stride.py::test_stride_cleartext_transmission_is_info_disclosure", "tests/test_sarif_stride.py::test_stride_cwe_normalisation_variants[306]", "tests/test_sarif_stride.py::test_stride_cwe_normalisation_variants[CWE-306]", "tests/test_sarif_stride.py::test_stride_cwe_normalisation_variants[CWE306]", "tests/test_sarif_stride.py::test_stride_cwe_normalisation_variants[cwe 306]", "tests/test_sarif_stride.py::test_stride_default_for_no_cwe", "tests/test_sarif_stride.py::test_stride_default_for_unmapped_cwe", "tests/test_sarif_stride.py::test_stride_hardcoded_credentials_is_spoofing", "tests/test_sarif_stride.py::test_stride_idor_is_elevation", "tests/test_sarif_stride.py::test_stride_missing_authorization_is_elevation", "tests/test_sarif_stride.py::test_stride_sql_injection_is_tampering_not_spoofing", "tests/test_sarif_stride.py::test_stride_tags_attach_to_rule_not_duplicated_on_result", "tests/test_sarif_stride.py::test_stride_tags_on_rule_for_known_cwe", "tests/test_session_entries.py::test_copied_source_becomes_localdir_entry", "tests/test_session_entries.py::test_incomplete_sources_are_skipped", "tests/test_session_entries.py::test_mixed_sources_split_correctly", "tests/test_session_entries.py::test_mounted_source_becomes_bind_mount", "tests/test_state_repo_context.py::test_parse_repo_full_name_handles_common_forms", "tests/test_state_repo_context.py::test_repository_context_derives_commit_and_branch_from_clone", "tests/test_state_repo_context.py::test_repository_context_none_for_multiple_repository_targets", "tests/test_state_repo_context.py::test_repository_context_none_for_non_repository_targets", "tests/test_state_repo_context.py::test_repository_context_uri_only_without_clone"], "notes": "Requirement texts are not yet written for mined triples; the pull requests are given instead. B patches are hand ports onto S+A; mining/strix/README.md lists what each port leaves out."}