Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
13 changes: 12 additions & 1 deletion python/packages/foundry_hosting/tests/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -3645,7 +3646,7 @@ def _make_consent_error(
"errors": [
{
"name": name,
"type": "mcp",
"type": source_type,
"error": {
"code": "CONSENT_REQUIRED",
"message": url,
Expand All @@ -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")
]
Comment on lines +3667 to +3675

def test_returns_none_when_no_mcp_error_in_args(self) -> None:
assert consent_url_from_error(Exception("boom")) is None

Expand Down
Loading