Repository navigation
Commit 156f007
refactor(workflow): deduplicate callable invocation, parameter resolution, and HITL helpers
Consolidate duplicated execution and Human-in-the-Loop (HITL) plumbing across `FunctionNode`, `_ToolNode`, `FunctionTool`, and `McpTool`:
- Move `_is_async_callable` and `_invoke_callable` into `utils/_sync_runner.py` so `FunctionNode`, `FunctionTool`, and `McpTool` share the same sync/async callable dispatcher.
- Fix async callable handling: unwrap `functools.partial` around async callable instances via `utils._sync_runner._invoke_callable` instead of returning an unawaited coroutine object, and await awaitable return values from sync callable wrappers.
- Extract `FunctionNode._resolve_parameters` and `_ResolvedParameters` to eliminate duplicate parameter lookup and coercion loops between `_bind_parameters` and `_validate_input_data`, ensuring `node_input` parameters are validated and coerced once per invocation.
- Extract `auth_interrupt_id`, `apply_confirmation_resume`, and `create_confirmation_request_input` into `workflow/utils/_workflow_hitl_utils.py` and use them in both `FunctionNode` and `_ToolNode`.
Co-authored-by: Shangjie Chen <[email protected]>
PiperOrigin-RevId: 9999451461 parent 9a5510e commit 156f007
10 files changed
Lines changed: 475 additions & 174 deletions
File tree
- src/google/adk
- tools
- mcp_tool
- utils
- workflow
- utils
- tests/unittests
- tools
- utils
- workflow
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
325 | 326 | | |
326 | 327 | | |
327 | 328 | | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
328 | 333 | | |
329 | 334 | | |
330 | 335 | | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
335 | 344 | | |
336 | 345 | | |
337 | 346 | | |
| |||
491 | 500 | | |
492 | 501 | | |
493 | 502 | | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
501 | 507 | | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
| 508 | + | |
508 | 509 | | |
509 | 510 | | |
510 | 511 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| 55 | + | |
| 56 | + | |
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
| |||
181 | 184 | | |
182 | 185 | | |
183 | 186 | | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | 187 | | |
198 | 188 | | |
199 | 189 | | |
| |||
510 | 500 | | |
511 | 501 | | |
512 | 502 | | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
518 | 506 | | |
519 | 507 | | |
520 | 508 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
0 commit comments