Commit d0a73a5
fix(runner): skip tool calls SessionToolRunner does not own
A self-hosted managed-agents session is commonly serviced by two clients
at once: the SessionToolRunner inside the customer's sandbox (registered
with the file/shell tools) and the customer's app backend (handling the
agent's custom function tools). The Sessions API has a partial-fulfilment
contract: when a session pauses requires_action the pending tool-call ids
can mix both kinds, and each client must post results ONLY for the ids it
owns and leave the rest pending for the other client to fill.
Previously execute() answered any unregistered tool name in place with an
is_error "tool not implemented" result. In the split-client setup that
claims a tool_use_id the runner does not own: the server either rejects
the type-mismatched result or the model reads "not implemented" as the
tool output while the real result from the app backend arrives after the
agent already sampled. Either way the conversation is corrupted.
Now an unregistered tool name is skipped unconditionally: the runner
posts no result, does not mark the id answered, and leaves it pending for
its owner, while still yielding the DispatchedToolCall (Posted=false,
IsError=false, no result event built) so the caller can observe the
unowned dispatch. A skipped, unanswered id stays out of the reconcile
idle/end-turn accounting and is re-surfaced after a reconnect until its
owner answers it. The comma-ok registry lookup is kept, so an
unregistered name never dereferences a nil tool.
Consequence for the single-client case: when this runner is the only
watcher of a session, an unowned tool call now gets no result or error
from anyone, so the session can stall silently rather than receiving the
old graceful "not implemented" error. An opt-in strict/error-on-unknown
mode is explored separately in a stacked PR (see linked exploration
ticket).1 parent 2888573 commit d0a73a5
3 files changed
Lines changed: 150 additions & 22 deletions
File tree
- examples/managed-agents-observe-tool-calls
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
151 | 153 | | |
152 | 154 | | |
153 | 155 | | |
| |||
195 | 197 | | |
196 | 198 | | |
197 | 199 | | |
198 | | - | |
199 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
200 | 204 | | |
201 | 205 | | |
202 | 206 | | |
| |||
886 | 890 | | |
887 | 891 | | |
888 | 892 | | |
889 | | - | |
890 | | - | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
891 | 905 | | |
892 | 906 | | |
893 | 907 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
423 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
424 | 432 | | |
425 | 433 | | |
426 | 434 | | |
427 | | - | |
| 435 | + | |
| 436 | + | |
428 | 437 | | |
429 | 438 | | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
| 439 | + | |
| 440 | + | |
435 | 441 | | |
436 | 442 | | |
| 443 | + | |
| 444 | + | |
437 | 445 | | |
438 | 446 | | |
439 | | - | |
| 447 | + | |
440 | 448 | | |
441 | | - | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
442 | 514 | | |
443 | | - | |
444 | | - | |
445 | | - | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
446 | 535 | | |
447 | 536 | | |
448 | 537 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
367 | 375 | | |
368 | 376 | | |
369 | | - | |
| 377 | + | |
| 378 | + | |
370 | 379 | | |
| 380 | + | |
| 381 | + | |
371 | 382 | | |
372 | 383 | | |
373 | | - | |
| 384 | + | |
374 | 385 | | |
375 | 386 | | |
376 | 387 | | |
377 | 388 | | |
378 | 389 | | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
379 | 404 | | |
380 | 405 | | |
381 | 406 | | |
| |||
0 commit comments