#1658·adk-go

workflow: a reply to a tool confirmation or consent request restarts the graph instead of resuming the paused AgentNode

Author: wolo-labCreated Sep 28, 2026Updated Sep 29, 2026
Labelsbug

Summary

An LlmAgent wrapped in an AgentNode can pause inside a graph on a tool's long-running request — interactive OAuth consent (adk_request_credential) or tool confirmation (adk_request_confirmation) — exactly as it does when it runs as a root agent. Pausing works: the scheduler parks the node on the generic Event.LongRunningToolIDs signal. Resuming does not. Submitting the matching FunctionResponse on the next turn starts a brand-new Workflow.Run instead of resuming the paused one, so every already-completed upstream node runs a second time and the tool that asked for the user's decision is never executed.

Only adk_request_input is recognised as a resume. Every other long-running request the same engine is able to pause on is treated as an unrelated turn.

Versions

Reproduced on google.golang.org/adk/v2 v2.4.0 and on main at 619e6d9.

Reproduction

A two-node graph, upstream → gated, with fake agents so there is no model and no network. upstream counts its activations. gated pauses the way a confirmed tool does: a FunctionCall named adk_request_confirmation whose ID is listed in LongRunningToolIDs. Turn 1 runs the graph and parks it. Turn 2 submits the approval.

go test -run TestConfirmationReplyRestartsGraph -count=1 -v

Actual output:

--- FAIL: TestConfirmationReplyRestartsGraph
    main_test.go:136: after the approval, upstream ran 2 times, want 1 (the approval restarted the graph)
main_test.go — self-contained, only adk/v2 and genai
go
package repro

import (
	"context"
	"iter"
	"sync/atomic"
	"testing"

	"google.golang.org/genai"

	"google.golang.org/adk/v2/agent"
	"google.golang.org/adk/v2/agent/workflowagent"
	"google.golang.org/adk/v2/runner"
	"google.golang.org/adk/v2/session"
	"google.golang.org/adk/v2/workflow"
)

const confirmationCallName = "adk_request_confirmation"

// counting is an agent that records how many times it ran and emits a
// plain final response.
func counting(name string, runs *atomic.Int32) agent.Agent {
	a, err := agent.New(agent.Config{
		Name: name,
		Run: func(ctx agent.InvocationContext) iter.Seq2[*session.Event, error] {
			return func(yield func(*session.Event, error) bool) {
				runs.Add(1)
				ev := session.NewEvent(ctx, ctx.InvocationID())
				ev.Author = name
				ev.Content = &genai.Content{
					Role:  genai.RoleModel,
					Parts: []*genai.Part{{Text: "done"}},
				}
				yield(ev, nil)
			}
		},
	})
	if err != nil {
		panic(err)
	}
	return a
}

// pausing is an agent that pauses on a tool confirmation request, the
// same shape tool.WithConfirmation produces: a FunctionCall named
// adk_request_confirmation whose ID is listed in LongRunningToolIDs.
func pausing(name, callID string) agent.Agent {
	a, err := agent.New(agent.Config{
		Name: name,
		Run: func(ctx agent.InvocationContext) iter.Seq2[*session.Event, error] {
			return func(yield func(*session.Event, error) bool) {
				ev := session.NewEvent(ctx, ctx.InvocationID())
				ev.Author = name
				ev.Content = &genai.Content{
					Role: genai.RoleModel,
					Parts: []*genai.Part{{
						FunctionCall: &genai.FunctionCall{
							ID:   callID,
							Name: confirmationCallName,
							Args: map[string]any{"hint": "delete everything?"},
						},
					}},
				}
				ev.LongRunningToolIDs = []string{callID}
				yield(ev, nil)
			}
		},
	})
	if err != nil {
		panic(err)
	}
	return a
}

func TestConfirmationReplyRestartsGraph(t *testing.T) {
	var upstreamRuns atomic.Int32

	up, err := workflow.NewAgentNode(counting("upstream", &upstreamRuns), workflow.NodeConfig{})
	if err != nil {
		t.Fatal(err)
	}
	down, err := workflow.NewAgentNode(pausing("gated", "conf-1"), workflow.NodeConfig{})
	if err != nil {
		t.Fatal(err)
	}

	root, err := workflowagent.New(workflowagent.Config{
		Name:  "graph",
		Edges: workflow.Chain(workflow.Start, up, down),
	})
	if err != nil {
		t.Fatal(err)
	}

	r, err := runner.New(runner.Config{
		AppName:           "repro",
		Agent:             root,
		SessionService:    session.InMemoryService(),
		AutoCreateSession: true,
	})
	if err != nil {
		t.Fatal(err)
	}

	ctx := context.Background()

	// Turn 1: run the graph. upstream completes, gated pauses.
	for _, err := range r.Run(ctx, "u", "s", genai.NewContentFromText("go", genai.RoleUser), agent.RunConfig{}) {
		if err != nil {
			t.Fatalf("turn 1: %v", err)
		}
	}
	if got := upstreamRuns.Load(); got != 1 {
		t.Fatalf("after turn 1, upstream ran %d times, want 1", got)
	}

	// Turn 2: the user approves. The reply targets the interrupt the
	// gated node raised.
	reply := &genai.Content{
		Role: genai.RoleUser,
		Parts: []*genai.Part{{
			FunctionResponse: &genai.FunctionResponse{
				ID:       "conf-1",
				Name:     confirmationCallName,
				Response: map[string]any{"confirmed": true},
			},
		}},
	}
	for _, err := range r.Run(ctx, "u", "s", reply, agent.RunConfig{}) {
		if err != nil {
			t.Fatalf("turn 2: %v", err)
		}
	}

	if got := upstreamRuns.Load(); got != 1 {
		t.Errorf("after the approval, upstream ran %d times, want 1 (the approval restarted the graph)", got)
	}
}

Three separate things stand between the reply and the paused node

All line references are pinned to 619e6d9.

Resume detection matches on the function name, while the pause does not. workflowagent.detectResume skips every FunctionResponse whose name is not adk_request_input. The engine parks a node on the generic LongRunningToolIDs signal regardless of name, so a graph can pause on a request it can never be resumed from. That mismatch is what the reproduction above measures.

An AgentNode over an LlmAgent never re-enters. A nil NodeConfig.RerunOnResume means handoff, and Workflow.Resume re-enters only when it is explicitly true. So even on the path that does resume today, the node is marked completed with the raw reply standing in for its output, the agent is never re-run, and the tool call that requested consent stays pending forever. A caller can set the field, but it has to know to.

The same reply decodes to different values depending on which path reads it. There are three decoders and they disagree. runner.decodeResumeResponse and workflowagent.decodeWorkflowInputResponse return Response["payload"] whenever that key is present, even in a multi-key map, so a tool confirmation reply shaped {"confirmed": b, "payload": v} silently loses confirmed. Neither of them recognises {"result": v}, which is what adk-python's _wrap_response produces and what the web frontend sends for user text. The third decoder, workflow.unwrapResponse on the session-history scan, handles both cases correctly, so a reply read back from history and the same reply taken from the inbound turn can yield different values.

Parity with adk-python

In adk-python 2.10.0, build_node defaults an LlmAgent node to rerun_on_resume=True (google/adk/workflow/utils/_workflow_graph_utils.py, in the isinstance(node_like, LlmAgent) branch), so an LlmAgent node there re-runs from history on resume rather than handing the raw reply to its successor. adk-go's engine default for the same node kind is handoff.

Expected behaviour

  • A FunctionResponse answering an interrupt raised inside the graph resumes that run, whatever the request was named. Completed upstream nodes do not run again.
  • The paused agent is re-entered so the tool call the user just authorised actually executes.
  • A given FunctionResponse decodes to the same value whether it is read from the inbound turn or from session history, including the multi-key confirmation shape and the {"result": v} shape.