Skip to content

feat(harness): relay MCP URL elicitations to the person as input-required - #3500

Open
QuentinBisson wants to merge 19 commits into
kagent-dev:mainfrom
QuentinBisson:feat/harness-relay-url-elicitations
Open

QuentinBisson wants to merge 19 commits into
kagent-dev:mainfrom
QuentinBisson:feat/harness-relay-url-elicitations

Conversation

@QuentinBisson

@QuentinBisson QuentinBisson commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Part of #3499.

Adds url_elicitation_request / url_elicitation_response to the HITL extension, and wires it in the Go ADK runtime: a URL elicitation during a tool call parks the task at input-required, and accept retries the call. For a server on MCP 2026-07-28, the retry sends back its requestState and input responses, kept in runtime session state across the pause. When the elicitation shares the pause with other calls, each tool in tool_approval_request carries it as a typed url_elicitation. The text part always carries the URL, so existing clients still show the link. Form mode is declined. When a server asks for several URLs at once, the call pauses on the first and leaves the others unanswered, so the server asks again; a call resumed from a confirmation cannot pause a second time in ADK Go (google/adk-go#1538), so a further URL elicitation fails it explicitly.

Claude and Codex, UI rendering, and forwarding through subagents follow in separate PRs.

AI assistance: used to port this from our fork.

@supreme-gg-gg supreme-gg-gg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI-generated review. These two comments were reviewed and approved for posting by the user.

Comment thread go/adk/pkg/mcp/url_elicitation.go Resolved
Comment thread go/adk/pkg/a2a/hitl.go Resolved

@supreme-gg-gg supreme-gg-gg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is looking good at a high level, a few Codex comments. I'm also wondering if you are planning to add support for forwarding URL elicitation through subagents in this PR or as a follow-up?

@QuentinBisson

QuentinBisson commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

On forwarding through subagents: follow-up, tracked on #3499 with the other follow-ups. Today a subagent's URL elicitation surfaces as an explicit error on the parent rather than being dropped. Teaching nested forwarding (RemoteHitlState) the new type depends on this payload shape.

@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 3, 2026
@QuentinBisson
QuentinBisson force-pushed the feat/harness-relay-url-elicitations branch from 109456d to 95c449d Compare November 3, 2026 18:26

@supreme-gg-gg supreme-gg-gg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI-generated review. This comment was reviewed and approved for posting by the user.

Comment thread go/adk/pkg/mcp/url_elicitation.go Resolved
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 3, 2026
@QuentinBisson
QuentinBisson force-pushed the feat/harness-relay-url-elicitations branch from 29090f7 to d5a7689 Compare November 3, 2026 23:15
supreme-gg-gg
supreme-gg-gg previously approved these changes Nov 4, 2026
@supreme-gg-gg
supreme-gg-gg dismissed their stale review November 4, 2026 16:44

failing lint

@supreme-gg-gg

Copy link
Copy Markdown
Contributor

@QuentinBisson

Copy link
Copy Markdown
Contributor Author

Thanks i'll fix that first thing tomorrow :)

@QuentinBisson

Copy link
Copy Markdown
Contributor Author

CI is fixed

@QuentinBisson
QuentinBisson force-pushed the feat/harness-relay-url-elicitations branch from 6f44c9f to ed2f3b1 Compare November 7, 2026 01:48
QuentinBisson added a commit to giantswarm/kagent-upstream that referenced this pull request Nov 9, 2026
… the HITL extension

The kagent UI activates the HITL extension and renders only the text of a
URL elicitation, so the text it receives carries the server's message and
the URL again, as kagent-dev#3500 does. A client without the
extension still gets the server's name alone. The refusal wording follows

Signed-off-by: QuentinBisson <[email protected]>
kagent-dev#3500's.
QuentinBisson added a commit to giantswarm/kagent-upstream that referenced this pull request Nov 9, 2026
QuentinBisson added a commit to giantswarm/kagent-upstream that referenced this pull request Nov 9, 2026
…the same status text

A child agent's URL elicitation was relayed to the person with only a
non-empty check on its URL. Every runtime now refuses a URL that is not
https, or http on a loopback host, or that carries user info, as
kagent-dev#3500 does: an MCP server's elicitation with such a URL is
declined, a child's is not relayed, and the harness fails the turn.

The harness put the server's name alone in the status text for every
caller and sent the typed request, URL included, to a caller without the
HITL extension. It now composes the text from the shared
URLElicitationText, so the kagent UI shows the link for Claude and Codex
agents as it does for Go ADK ones, and answers the elicitation with cancel
for a caller without the extension.

A failed client lookup when canceling a child's task is logged.

Signed-off-by: QuentinBisson <[email protected]>
QuentinBisson added a commit to giantswarm/kagent-upstream that referenced this pull request Nov 9, 2026
MCP 2026-07-28 says a client should warn when an elicitation URL's host
holds Punycode or non-ASCII characters, which can imitate another domain.
ValidateElicitationURL keeps accepting such a host, as
kagent-dev#3500 does; the status text of a client that activated
the HITL extension now names the host's ASCII form and asks the person
to check it.
QuentinBisson added a commit to giantswarm/kagent-upstream that referenced this pull request Nov 10, 2026
MCP 2026-07-28 says a client should warn when an elicitation URL's host
holds Punycode or non-ASCII characters, which can imitate another domain.
ValidateElicitationURL keeps accepting such a host, as
kagent-dev#3500 does; the status text of a client that activated
the HITL extension now names the host's ASCII form and asks the person
to check it.
QuentinBisson added a commit to giantswarm/kagent-upstream that referenced this pull request Nov 10, 2026
… the HITL extension

The kagent UI activates the HITL extension and renders only the text of a
URL elicitation, so the text it receives carries the server's message and
the URL again, as kagent-dev#3500 does. A client without the
extension still gets the server's name alone. The refusal wording follows

Signed-off-by: QuentinBisson <[email protected]>
kagent-dev#3500's.
QuentinBisson added a commit to giantswarm/kagent-upstream that referenced this pull request Nov 10, 2026
QuentinBisson added a commit to giantswarm/kagent-upstream that referenced this pull request Nov 10, 2026
…the same status text

A child agent's URL elicitation was relayed to the person with only a
non-empty check on its URL. Every runtime now refuses a URL that is not
https, or http on a loopback host, or that carries user info, as
kagent-dev#3500 does: an MCP server's elicitation with such a URL is
declined, a child's is not relayed, and the harness fails the turn.

The harness put the server's name alone in the status text for every
caller and sent the typed request, URL included, to a caller without the
HITL extension. It now composes the text from the shared
URLElicitationText, so the kagent UI shows the link for Claude and Codex
agents as it does for Go ADK ones, and answers the elicitation with cancel
for a caller without the extension.

A failed client lookup when canceling a child's task is logged.

Signed-off-by: QuentinBisson <[email protected]>
QuentinBisson added a commit to giantswarm/kagent-upstream that referenced this pull request Nov 10, 2026
MCP 2026-07-28 says a client should warn when an elicitation URL's host
holds Punycode or non-ASCII characters, which can imitate another domain.
ValidateElicitationURL keeps accepting such a host, as
kagent-dev#3500 does; the status text of a client that activated
the HITL extension now names the host's ASCII form and asks the person
to check it.
… pause

A server on MCP 2026-07-28 that asks for a URL elicitation through an
input_required result needs its request state and input responses back
when the call runs again. Answer input_required results in our own
middleware, keep the continuation in session state under the call ID, and
send it with the confirmed call.

Signed-off-by: QuentinBisson <[email protected]>
When a URL elicitation shares its pause with other calls it is presented
as a tool approval. The tool now carries the URL elicitation typed, so a
client renders it the same way whatever else is pending.

Signed-off-by: QuentinBisson <[email protected]>
A client that activated the HITL extension before url_elicitation_request
existed renders only the text part, so the link has to be there.

Signed-off-by: QuentinBisson <[email protected]>
…ver as configured

A caller that did not activate the HITL extension read a URL elicitation
as status text that carried the URL, and an agent calling over A2A hands
that text to its model. The tool call now fails for such a caller, with
an error that names the server and not the URL, and the text it would
receive names the server alone. A client that activated the extension
still gets the URL in the text.

The server was named by its self-reported ServerInfo.Name, so a server
could present its link under another's name. It is now named by its
configured entry: a name on the ADK's MCP server config, from the
RemoteMCPServer's name or the mcp.json key, else its host.

Signed-off-by: QuentinBisson <[email protected]>
@QuentinBisson
QuentinBisson force-pushed the feat/harness-relay-url-elicitations branch from 76ea28b to f298e04 Compare November 19, 2026 09:15
@supreme-gg-gg

Copy link
Copy Markdown
Contributor

Hey @QuentinBisson Sorry the PR got buried in the stack, can you resolve the conflicts and I'll take another look, this would be great to get in

@QuentinBisson

Copy link
Copy Markdown
Contributor Author

Hey @supreme-gg-gg no worries, I know you were busy with Kubecon and the 1.0.0 release and I have quite a few PRs so I understand :D I'm resolving the conflicts

@supreme-gg-gg

supreme-gg-gg commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

I've found a few issues and places for simplifications and I'll comment them below. Another gap that I've found is that this also needs to be integrated with Kagent's MCP server bridge (for those invoking Kagent agents over MCP), similar to subagent's case. I think we should include all 3 follow ups in the same PR (UI + subagent + MCP bridge), at least UI, since right now the chat UI cannot complete the URL flow, so it's hard to see the feature in action and this feature is not complete. What do you think?

For UI, it's be best to include a screenshot or recording for the UI team to review

@supreme-gg-gg supreme-gg-gg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI-generated review. I’ve grouped the inline comments into six issues to address and three simplifications.

}
// ADK does not pause a call that resumes from a confirmation again: a
// second RequestConfirmation is recorded and the model runs on.
if confirmation != nil {

@supreme-gg-gg supreme-gg-gg Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must address 1 — clarify the first sign-in failure on an approval-gated tool. With require_approval: true, the person first approves running the tool. If the MCP server then requests sign-in, that is the first URL elicitation but the second ADK confirmation. The pinned ADK cannot deliver that second pause, so keeping this guard makes sense. Could the error say “Tool %q already resumed after approval and cannot pause for the URL requested by %s” and could the HITL guide mention this configuration explicitly? Clear wording and documentation are sufficient for this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Error reworded; the guide says not to set requireApproval on a binding to a server that asks for URL elicitations.

Comment thread go/adk/pkg/a2a/hitl.go
// IsHITLResponse reports whether a Message carries a valid HITL response.
func IsHITLResponse(message *a2atype.Message) bool {
return GetToolApprovalResponse(message) != nil || GetAskUserResponse(message) != nil
return GetToolApprovalResponse(message) != nil || GetAskUserResponse(message) != nil || GetURLElicitationResponse(message) != nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must address 2 — validate a URL decision before advancing the task. A message tagged url_elicitation_response with a missing or unknown action fails parsing, so IsHITLResponse returns false and the executor hands it to ADK as ordinary input. With a valid action and the wrong ID, the executor emits working before checking correlation. Could we recognize the declared response type first, validate the action and pending ID, and only then publish working? In both cases the client should get an error and the original pause should stay answerable. Executor ordering

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done for all three response types. A CallInterceptor checks the decision against the stored task before a2a-go touches it and returns invalid-params, so the pause stays answerable. The executor alone cannot do it: working is already published by then.

Comment thread go/adk/pkg/a2a/hitl.go Outdated
if text == "" {
text = fmt.Sprintf("%s asks you to open a link to continue.", request.Server)
}
return fmt.Sprintf("%s %s", text, request.URL)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must address 3 — include the configured requester in the text fallback. When request.Message is populated, the text contains only server-authored prose and the URL. A text-only client can show “Sign in to GitHub” without telling the person which configured MCP server asked. Please include request.Server alongside the destination even when a message is present. This helper serves both standalone and batched pauses. MCP user interaction requirements

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: <server> asks: <message> <url>.

Comment thread go/adk/pkg/mcp/url_elicitation.go Outdated
if options.Capabilities == nil {
options.Capabilities = &mcpsdk.ClientCapabilities{}
}
options.Capabilities.Elicitation = &mcpsdk.ElicitationCapabilities{Form: &mcpsdk.FormElicitationCapabilities{}, URL: &mcpsdk.URLElicitationCapabilities{}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must address 4 — align the advertised modes and docs with the supported flows. Could we advertise URL mode only while every form is automatically declined? A server that checks capabilities can currently choose a form the person will never see. The architecture guide should also distinguish the two 2025-11-25 URL paths: a tools/call error -32042 can park and retry, while a live elicitation/create callback receives an RPC error. The 2026-07-28 input_required result is the supported continuation path. Documenting the callback limitation is sufficient for this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. URL mode only; the guide lists the two paths separately.

if !ok || toolResult.InputRequests == nil {
return result, nil
}
if round == maxInputRequiredRounds {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must address 5 — preserve the SDK’s busy-server retry limit. A non-nil, empty inputRequests map is a load-shedding signal. The pinned SDK stops on the third such response. This replacement loop immediately retries until the ten-round general limit, so a continuously busy server receives ten calls for the same invocation instead of three, even when no elicitation occurs. Please preserve the separate empty-map budget and cover this case. SDK retry loop

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Separate budget for empty inputRequests, stops at 3, with a test.

Comment thread go/api/a2a/hitl.go
// URLElicitation is set when the call waits on an MCP server's URL
// elicitation: the person opens its URL, and approving the call means they
// completed the interaction there, as a URL elicitation response's accept.
URLElicitation *URLElicitationRequest `json:"url_elicitation,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must address 6 — apply URL validation to batched requests too. ParseURLElicitationRequest validates the standalone URL, while ParseToolApprovalRequest accepts the same URL inside a tool without checking it. A client using the public parsers gets a different guarantee depending on which other calls happened to pause. Please apply the same check to URL-bearing entries in Tools and Nested.Tools, and have the ADK approval reader use the validated path while preserving its argument normalization.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. URLs in batched Tools and Nested.Tools are checked.

Comment thread go/adk/pkg/mcp/url_elicitation.go Outdated
if request.Params.Mode != "url" || apia2a.ValidateElicitationURL(request.Params.URL) != nil {
return &mcpsdk.ElicitResult{Action: "decline"}, nil
}
return nil, &urlElicitationError{request: urlElicitationRequest(server, request.Params)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplification 1 — return a plain error from the live callback. This error crosses JSON-RPC back to the MCP server, so constructing a typed request here has no effect on the tool wrapper. A short error explaining the unsupported callback would be clearer. Keep the typed error in the local sending middleware, where the wrapper actually consumes it, and assert the callback’s observable result in its test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Plain error from the callback, with a test against a 2025-11-25 server.

Comment thread go/adk/pkg/a2a/hitl.go Outdated
// input-required task: accept confirms the tool call, which then runs again;
// decline and cancel reject it.
func resumeURLElicitation(storedTask *a2atype.Task, incoming *a2atype.Message) (*a2atype.Message, error) {
request := GetURLElicitationRequest(storedTask.Status.Message)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplification 2 — decode the pending request once. BuildResumeHITLMessage has already parsed this request. Passing it into resumeURLElicitation removes the second decode and nil check. The confirmation payload parser above can also reuse decodeJSON[T] followed by URL validation, and the rejection payload can use the existing ToolConfirmationRejectionReasonKey.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread go/adk/pkg/a2a/hitl.go Outdated
hint := tool.hint
if candidate := parseURLElicitation(tool.payload); candidate != nil {
candidate.ID = hitlTool.ID
elicitation = candidate

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplification 3 — use the URL already attached to the tool. After the loop, len(tools) == 1 && tools[0].URLElicitation != nil identifies the standalone case without a separate elicitation variable. In the text renderer, compute the configured-server fallback once and keep its URL redaction for callers without HITL.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

ParseToolApprovalRequest now applies the URL check of
ParseURLElicitationRequest to the url_elicitation of every tool and
nested tool, and the Go ADK reads a stored tool approval through it.

Signed-off-by: QuentinBisson <[email protected]>
The status text of a URL elicitation now names the configured server
that asked even when the server sent a message, so a text-only client
does not show server-authored prose without its requester.

A pause on one URL elicitation is identified by the tool that carries
it, and the stored request is decoded once on resume.

Signed-off-by: QuentinBisson <[email protected]>
The MCP client declares URL mode elicitation only, since every form is
declined. A live elicitation/create request for a URL gets a plain error
back, which is all the server sees. input_required results with an empty
inputRequests map stop after three rounds, as in the SDK's multi round-trip
middleware. A confirmed call that cannot pause again names the approval it
resumed from, and the HITL guide documents requireApproval with URL
elicitation and the two 2025-11-25 paths.

Signed-off-by: QuentinBisson <[email protected]>
A message that declares a HITL response type is a decision, even when it
does not parse, and is never handed to ADK as ordinary input. A
CallInterceptor checks it against the stored pause with the public
contract's parsers and validators, and returns an invalid-params error
before the task is touched, so the pause stays answerable for every
runtime the Go app serves. The ADK executor builds the resume before it
publishes working.

Signed-off-by: QuentinBisson <[email protected]>
@QuentinBisson

Copy link
Copy Markdown
Contributor Author

Thanks. I'd keep this PR to the contract and Go ADK and follow up with stacked PRs: UI first (with a recording), then subagent forwarding. The MCP bridge has a catch: MCP accept means "opened the link", not "finished", and a resumed call can't pause again (google/adk-go#1538), so I'd track it as a gap until that's fixed. Happy to fold the UI in here if you prefer.

AI assistance: drafted with an AI assistant, reviewed and edited by me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants