mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-01 02:02:20 +00:00
fix(agents): bill the path target on explicit A2A routes
This commit is contained in:
parent
5369f14a38
commit
91bc86afd8
2 changed files with 6 additions and 4 deletions
|
|
@ -208,12 +208,12 @@ _INVOCATION_COST: Final = TypeAdapter(Annotated[float, Field(ge=0, allow_inf_nan
|
|||
|
||||
|
||||
def invocation_target(route: str, body: Mapping[str, object]) -> str | None:
|
||||
model: Final = body.get("model")
|
||||
if isinstance(model, str) and model.startswith("a2a/"):
|
||||
return model.removeprefix("a2a/") or None
|
||||
components: Final = tuple(route.strip("/").split("/"))
|
||||
path: Final = components[1:] if components and components[0] == "v1" else components
|
||||
return path[1] if len(path) >= 2 and path[0] == "a2a" else None
|
||||
if len(path) >= 2 and path[0] == "a2a":
|
||||
return path[1]
|
||||
model: Final = body.get("model")
|
||||
return model.removeprefix("a2a/") or None if isinstance(model, str) and model.startswith("a2a/") else None
|
||||
|
||||
|
||||
async def prepare_agent_invocation(
|
||||
|
|
|
|||
|
|
@ -198,6 +198,8 @@ async def test_agent_history_outage_does_not_permit_legacy_fallback() -> None:
|
|||
"route,body,expected",
|
||||
[
|
||||
("/a2a/agent", {}, "agent"),
|
||||
("/a2a/agent", {"model": "a2a/nonexistent"}, "agent"),
|
||||
("/v1/a2a/agent/message/send", {"model": "a2a/other"}, "agent"),
|
||||
("/v1/a2a/agent/", {}, "agent"),
|
||||
("/v1/chat/completions", {"model": "a2a/Readable name"}, "Readable name"),
|
||||
("/v1/chat/completions", {"model": "a2a/"}, None),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue