ag-ui-protocol / ag-ui-protocol/ag-ui

feat(adk): enforced endpoint-level tool-call route pinning

Abierto
#1,994 0 comentarios 0 reacciones 0 asignados Ver en GitHub
enhancement Integration proposal
Lenguaje dominante
Python
Estrellas
15.9k
Forks
1.4k
Merge medio
1 d 17 h
PR fusionados (30 d)
163

Descripción

### Background

PR #1846 (issue #1723) added an opt-in `agent_resolver` hook to `add_adk_fastapi_endpoint`, plus a helper, `resolve_agent_from_message_history(messages, agent_registry)`, that a resolver can call to pin a tool-result resumption back to the agent that emitted the original tool call (matching `ToolMessage.tool_call_id` → prior `AssistantMessage.tool_calls[].id`, keyed by `AssistantMessage.name`).

That helper is the right **opt-in** primitive. This issue tracks the heavier, **enforced** variant we deferred.

### Problem

With the current design, honoring the HITL / long-running tool-call constraint is the resolver author's responsibility. If a resolver is misconfigured — or simply doesn't call the helper — an inbound `ToolMessage` can be routed to the wrong agent, silently stranding the open tool call (the originating agent's resumption paths never fire). The constraint is documented, and the helper makes it *achievable*, but nothing *enforces* it.

### Proposal

Have the endpoint itself pin the route when it detects an unresolved tool result, **before** the resolver runs:

1. Inspect inbound `messages` for a tool result whose matching `TOOL_CALL_START` originated from a known registered agent.
2. If found, pin routing to that agent and **skip** `agent_resolver` entirely (per the original semantics agreed in #1723).
3. Otherwise, fall through to the existing resolver → default-agent flow.

### Open questions

- **Registry source of truth.** Enforcement needs the endpoint to know the full set of routable agents. The current hook only knows a `default_agent` + an opaque resolver. This likely wants an explicit registry collection passed at registration (the `AgentRouter(default=..., routes={...}, session_manager=...)` primitive floated in #1723), which could also validate the shared-session-backend requirement at registration time.
- **Cross-agent lookup.** Resolving "which agent originated this `tool_call_id`" reliably may require the shared session backend, not just inbound message history (the live-reducer-history gap called out in the PR docstring).
- **Precedence.** Confirm enforced pinning should hard-override a resolver that returns a different agent, or whether that should be a warning vs. an error.
- **Parallel tool calls / multiple pending results** in a single turn.

### Non-goals

- Changing `ADKAgent.from_app` (stays single-app).
- Replacing the opt-in helper from #1846 — this builds on top of it.

Related: #1723, #1846.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.