From d30b6a0df02eb402115fdf585484d1ab120315f6 Mon Sep 17 00:00:00 2001 From: LobsterQBA <101247207+LobsterQBA@users.noreply.github.com> Date: Mon, 10 Aug 2026 12:02:27 -0700 Subject: [PATCH] fix(foundry-hosting): surface A2A consent URLs --- .../agent_framework_foundry_hosting/_responses.py | 4 ++-- .../foundry_hosting/tests/test_responses.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py b/python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py index 6ff4550f7e..fa9e096c98 100644 --- a/python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py +++ b/python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py @@ -123,7 +123,7 @@ def consent_url_from_error(exc: BaseException) -> list[ConsentError] | None: # "errors" : [ # { # "name": "Name of the MCP tool that requires consent", - # "type" : "mcp", + # "type" : "mcp" | "a2a_preview", # "error": { # "code": "CONSENT_REQUIRED", # "message": consent_url, @@ -146,7 +146,7 @@ def consent_url_from_error(exc: BaseException) -> list[ConsentError] | None: for error in consent_details["errors"]: if ( isinstance(error, dict) - and error.get("type") == "mcp" # type: ignore + and error.get("type") in {"mcp", "a2a_preview"} # type: ignore and "error" in error and isinstance(error["error"], dict) and error["error"].get("code") == "CONSENT_REQUIRED" # type: ignore diff --git a/python/packages/foundry_hosting/tests/test_responses.py b/python/packages/foundry_hosting/tests/test_responses.py index 5b0dfda65c..fb1e93995f 100644 --- a/python/packages/foundry_hosting/tests/test_responses.py +++ b/python/packages/foundry_hosting/tests/test_responses.py @@ -3626,6 +3626,7 @@ async def test_workflow_rejects_invalid_checkpoint_scope( def _make_consent_error( url: str = "https://consent.example.com/auth", name: str = "Foundry Toolbox", + source_type: str = "mcp", ) -> Exception: """Build an exception wrapping a Foundry MCP gateway consent error. @@ -3645,7 +3646,7 @@ def _make_consent_error( "errors": [ { "name": name, - "type": "mcp", + "type": source_type, "error": { "code": "CONSENT_REQUIRED", "message": url, @@ -3663,6 +3664,16 @@ def test_returns_consent_url_when_inner_arg_is_consent_mcp_error(self) -> None: exc = _make_consent_error("https://example.com/consent", name="my-tool") assert consent_url_from_error(exc) == [ConsentError(name="my-tool", consent_url="https://example.com/consent")] + def test_returns_consent_url_for_a2a_preview_source(self) -> None: + exc = _make_consent_error( + "https://example.com/a2a-consent", + name="work-iq", + source_type="a2a_preview", + ) + assert consent_url_from_error(exc) == [ + ConsentError(name="work-iq", consent_url="https://example.com/a2a-consent") + ] + def test_returns_none_when_no_mcp_error_in_args(self) -> None: assert consent_url_from_error(Exception("boom")) is None