Commit 935ff2b
committed
feat: expose tool_call_id on RunContextWrapper for lifecycle hooks
Add a `tool_call_id: str | None` field (init=False, default None) to
`RunContextWrapper` so that callers of `on_tool_start` / `on_tool_end`
hooks can read the tool call ID directly from the context parameter
without needing an `isinstance(context, ToolContext)` guard.
`ToolContext` already declares `tool_call_id` as a required init field
(str, not str | None), so subclass behaviour is unchanged. The base
field is `init=False` to avoid clashing with `ToolContext.from_agent_context`
which copies base-class init fields by name.
Both `_fork_with_tool_input` and `_fork_without_tool_input` are updated
to propagate the value when forking.
Closes #18491 parent 4f3c8a5 commit 935ff2b
2 files changed
+59
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
64 | 74 | | |
65 | 75 | | |
66 | 76 | | |
| |||
461 | 471 | | |
462 | 472 | | |
463 | 473 | | |
| 474 | + | |
464 | 475 | | |
465 | 476 | | |
466 | 477 | | |
| |||
469 | 480 | | |
470 | 481 | | |
471 | 482 | | |
| 483 | + | |
472 | 484 | | |
473 | 485 | | |
474 | 486 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
318 | 319 | | |
319 | 320 | | |
320 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
0 commit comments