Garak sets a custom HTTP user-agent across all its HTTP libraries (requests, httpx, aiohttp) to identify itself as a vulnerability scanner; the default format includes version and is configured in garak.core.yaml and managed by _config.py. Users can override the user-agent globally via set_all_http_lib_agents() or per-library via set_http_lib_agents(), with requests receiving the custom agent through a monkey-patched closure on its default function.
The default HTTP user-agent string for garak is garak/{version} (LLM vulnerability scanner https://garak.ai), configured in garak/resources/garak.core.yaml.[1] During config loading, _store_config() in garak/_config.py calls run.user_agent.replace("{version}", version), so the {version} placeholder in the user-agent template is automatically substituted with the current garak version.[2]
garak/_config.py exposes set_all_http_lib_agents(agent_string) to apply the same user-agent string to requests, httpx, and aiohttp simultaneously, and set_http_lib_agents(agent_strings: dict) to set them individually by library name.[2] The requests override works by monkey-patching requests.utils.default_user_agent with a module-level closure that returns the configured REQUESTS_AGENT string.[2]
Sources