fix(agents): recognize versioned A2A invocation routes

This commit is contained in:
Joshua Valluru 2026-09-26 15:43:28 -07:00
parent 1dd343ae18
commit ccb4792ce0
3 changed files with 33 additions and 4 deletions

View file

@ -569,6 +569,7 @@ class LiteLLMRoutes(enum.Enum):
"/agents",
"/a2a/{agent_id}",
"/a2a/{agent_id}/message/send",
"/v1/a2a/{agent_id}/message/send",
"/a2a/{agent_id}/message/stream",
"/a2a/{agent_id}/.well-known/agent-card.json",
)

View file

@ -1,3 +1,4 @@
from collections.abc import Mapping
from typing import Final
import pytest
@ -112,6 +113,11 @@ def test_matching_identity_revision_and_execution_mode_pass_admission(mode: str,
("/v1/realtime/client_secrets", "POST", False),
("/mcp/tools/call", "POST", True),
("/a2a/target/message/send", "POST", True),
("/v1/a2a/target/message/send", "POST", True),
("/v1/videos", "POST", False),
("/v1/videos/other-video", "GET", False),
("/v1/search", "POST", False),
("/search", "POST", False),
("/v1/agents/target", "PATCH", False),
("/v1/responses/other-response", "GET", False),
("/v1/files", "GET", False),
@ -142,7 +148,14 @@ def test_managed_route_scope_excludes_provider_resources(route: str, method: str
("/v1beta/models/path:countTokens", {"model": "body"}, {"completion_model": "text"}, "cli", "path", "path"),
],
)
def test_managed_inference_resolves_dispatch_precedence(route, body, settings, cli_model, path_model, expected):
def test_managed_inference_resolves_dispatch_precedence(
route: str,
body: Mapping[str, object],
settings: Mapping[str, object],
cli_model: str | None,
path_model: str | None,
expected: str | None,
) -> None:
from litellm.proxy.agent_endpoints.auth.managed_authorization import managed_inference_request
assert managed_inference_request(route, body, settings, cli_model, path_model).get("model") == expected

View file

@ -1,6 +1,7 @@
import io
import json
from typing import get_type_hints
from collections.abc import Mapping
from typing import Literal, get_type_hints
from unittest.mock import AsyncMock, MagicMock, patch
import orjson
@ -1219,7 +1220,14 @@ class TestCoerceNumericFormFields:
("completion", {}, "cli", "path", "body", "cli"),
("completion", {}, None, "path", "body", "path"),
("completion", {}, None, None, "body", "body"),
("image_generation", {"completion_model": "text", "image_generation_model": "image"}, None, None, "body", "image"),
(
"image_generation",
{"completion_model": "text", "image_generation_model": "image"},
None,
None,
"body",
"image",
),
("image_generation", {"image_generation_model": "image"}, "cli", "path", "body", "cli"),
("image_generation", {"image_generation_model": "image"}, None, "path", "body", "path"),
("image_edit", {"completion_model": "text", "image_generation_model": "image"}, None, None, "body", "text"),
@ -1231,7 +1239,14 @@ class TestCoerceNumericFormFields:
("path", {"completion_model": "text"}, "cli", "path", "body", "path"),
],
)
def test_shared_inference_model_selection_preserves_handler_precedence(kind, settings, cli, path, body, expected):
def test_shared_inference_model_selection_preserves_handler_precedence(
kind: Literal["completion", "image_generation", "image_edit", "moderation", "speech", "body", "path"],
settings: Mapping[str, object],
cli: str | None,
path: str | None,
body: str,
expected: str,
) -> None:
from litellm.proxy.common_utils.http_parsing_utils import resolve_inference_model
assert resolve_inference_model(body, settings, cli, path, kind=kind) == expected