The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(mcp): pin the pre-flight discovery User-Agent in a test; drop the unfailing version import guard
teknium15a64a888dac3
diff --git a/tests/tools/test_mcp_oauth_cold_load_expiry.py b/tests/tools/test_mcp_oauth_cold_load_expiry.pyindex 13017d95020..867052512c6 100644--- a/tests/tools/test_mcp_oauth_cold_load_expiry.py+++ b/tests/tools/test_mcp_oauth_cold_load_expiry.py@@ -421,8 +421,11 @@ async def test_initialize_prefetches_oauth_metadata_when_missing(# MockTransport that mimics BetterStack's split-origin discovery:# PRM at mcp.example.com/.well-known/oauth-protected-resource -> points to auth.example.com# ASM at auth.example.com/.well-known/oauth-authorization-server -> token_endpoint at auth.example.com/oauth/token+ seen_user_agents: list = []+def mock_handler(request: httpx.Request) -> httpx.Response:url = str(request.url)+ seen_user_agents.append(request.headers.get("User-Agent"))if url.endswith("/.well-known/oauth-protected-resource"):return httpx.Response(200,@@ -489,6 +492,10 @@ async def test_initialize_prefetches_oauth_metadata_when_missing(assert str(provider.context.oauth_metadata.token_endpoint) == ("https://auth.example.com/oauth/token")+ # Pre-flight discovery requests are SDK-built (no client default headers merged),+ # so they must carry the stamped User-Agent or WAF-fronted providers 403 them (#113771).+ from tools.mcp_oauth_provider import DEFAULT_AUTH_REQUEST_USER_AGENT+ assert seen_user_agents and set(seen_user_agents) == {DEFAULT_AUTH_REQUEST_USER_AGENT}@pytest.mark.asynciodiff --git a/tools/mcp_oauth_provider.py b/tools/mcp_oauth_provider.pyindex cc145827e9d..6a35edc7c92 100644--- a/tools/mcp_oauth_provider.py+++ b/tools/mcp_oauth_provider.py@@ -27,10 +27,7 @@ _DISCOVERY_CONTEXT_LEAD = "Could not read authorization-server metadata"def _default_auth_request_user_agent() -> str:"""``Hermes-Agent/<version>`` for SDK-built OAuth requests that would otherwise carry no User-Agent atall; versioned so an operator debugging a WAF block can tell which client they are looking at."""- try:- from hermes_cli import __version__- except Exception: # pragma: no cover — defensive- __version__ = "unknown"+ from hermes_cli import __version__return f"Hermes-Agent/{__version__}"