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

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

未关闭
#1,994 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
enhancement Integration proposal
主要语言
Python
星标
15.9k
派生
1.4k
平均合并
1 天 17 小时
30 天内合并 PR
163

描述

### 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.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。