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 982f608
Browse filesBrowse the repository at this point in the historyBrowse files
fix: require confirmation before large reimbursements in hitl samples
Merge #7993
In the human_in_loop and tool_human_in_the_loop_config samples, reimburse
calls of $100 or more now pause for a tool confirmation instead of running
whenever the model calls them. The YAML sample's reimburse tool now takes a
tool_context. The A2A human-in-the-loop sample is unchanged.
Part of #7987
PiperOrigin-RevId: 1015684580
Copy file name to clipboardExpand all lines: contributing/samples/hitl/human_in_loop/README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,4 +47,6 @@ This example demonstrates an agent using a long-running tool (`ask_for_approval`
47
47
48
48
1.**Agent Acts on Update**: The agent receives this message containing the `types.FunctionResponse` and, based on its instructions, proceeds with the next steps (e.g., calling another tool like `reimburse`).
49
49
50
+
1.**Application Confirms the Reimbursement**: For amounts of $100 or more, `FunctionTool(require_confirmation=needs_manager_approval)` holds `reimburse` and emits `adk_request_confirmation`. The application answers with a `FunctionResponse` using that confirmation call's `id` and `name`, with a `ToolConfirmation` payload. In `main.py`, `answer_confirmations` confirms at most one call matching the approved ticket's amount and purpose (purpose compared ignoring case and surrounding whitespace); calls without approval are rejected. The instruction and the updated approval response alone do not authorize a reimbursement. The YAML sibling, `tool_human_in_the_loop_config`, gates the same call with `tool_context.request_confirmation()` inside `reimburse` instead, because `AgentConfig` YAML cannot express `require_confirmation` yet.
51
+
50
52
**Why is this important?** The agent relies on receiving this subsequent `types.FunctionResponse` (provided in a message with `role="user"` containing the specific `Part`) to understand that the long-running task has concluded or its state has changed. Without it, the agent will remain unaware of the outcome of the pending task.
0 commit comments