You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ce132b9
Browse filesBrowse the repository at this point in the historyBrowse files
feat(workflow): pause tool nodes for tool confirmation via RequestInput
A tool that requires confirmation behaved differently inside a workflow graph
than inside an LlmAgent. In an agent the call pauses until the user approves
or rejects it. In a tool node, the confirmation request was recorded on
`ctx.actions` where nothing handled it, and the placeholder
`{'error': 'This tool call requires confirmation, ...'}` was passed
downstream as the node output. The tool never ran.
Tool nodes now turn both ways a tool can ask for confirmation into a single
`RequestInput` (interrupt id `wf_tool_confirmation:<node_path>`, response
schema `ToolConfirmation`), and the workflow waits:
* Before the call, when `check_require_confirmation` returns True (for
example `FunctionTool(require_confirmation=...)`). Tool nodes reuse the
agent pipeline's confirmation gate (`tools/_confirmation_utils.py`),
which runs after the plugin before-tool callback. On resume, an
approval runs the tool once; a rejection answers with
`{'error': 'This tool call is rejected.'}` without running the tool.
After-tool plugin callbacks still see the rejected result.
* While the call runs, when the tool calls
`tool_context.request_confirmation(hint=..., payload=...)` (for example
`ExecuteBashTool`). The hint becomes the request message and the payload is
passed through as `confirmation_payload`. On resume, the tool reruns and
decides what to do with the answer, as it does inside an agent.
Both paths record the request on `ctx.actions.requested_tool_confirmations`,
and the tool node converts it into the `RequestInput` in one place. On resume
the answer is stored on `ctx.tool_confirmation` before any plugin tool
callback runs, as an agent sets it when building the `ToolContext`, so the
before-tool callback, the gate and the tool all see it, and a malformed answer
is not routed to `on_tool_error_callback`. Tool nodes are created with
`rerun_on_resume=True` so that confirmed calls can execute upon resume, and
`_replay_interceptor.py` fast-forwards tool nodes that completed without
output, both static ones and ones scheduled with `ctx.run_node()`, as well as
ones that already reran after their confirmation was answered, so their side
effects do not run again during workflow replay. A tool that raises after
requesting confirmation has its request dropped; the error (or the
`on_tool_error_callback` answer) is the call's result.
Behavior change: confirm-required tools in a graph now pause for the user
instead of emitting the placeholder output. Tools whose confirmation
predicate returns False run immediately as before.
Not in this change:
* `FunctionTool`, `McpTool`, `BashTool` and `ComputerUseTool` keep their
own copies of the confirmation check; they pass because
`ctx.tool_confirmation` is set before the tool runs. Switching them to
the shared gate can be a follow-up.
* Auth requests raised by tools inside tool nodes are still unhandled.
Tests: end-to-end workflow tests (resumable and non-resumable) for the pause,
approval and rejection paths of both confirmation styles (including
`ExecuteBashTool`), for the before-tool callback seeing the answer on resume,
for a predicate that does not require confirmation, for a failed call
dropping its confirmation request, and for static, dynamically scheduled and
confirmed tool nodes with no output not rerunning on resume.
Co-authored-by: Shangjie Chen <[email protected]>
PiperOrigin-RevId: 991938956
0 commit comments