Commit cefda44
Python: Emit TOOL_CALL_RESULT events when resuming after tool approval (#4758)
* Emit TOOL_CALL_RESULT events on approval resume (#4589)
When a tool call is approved via the interrupt/resume flow,
_resolve_approval_responses executes the tool and injects the result
into the messages array, but no TOOL_CALL_RESULT SSE event was yielded
to the client.
Changes:
- _resolve_approval_responses now returns the list of resolved
function_result Content objects instead of None
- run_agent_stream yields ToolCallResultEvent for each resolved
approval result after RunStartedEvent is emitted
- Add ToolCallResultEvent to ag_ui.core imports in _agent_run.py
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Apply pre-commit auto-fixes
* fix(ag-ui): address PR review feedback for #4589
1. _resolve_approval_responses now returns only approved results (not
rejections) so TOOL_CALL_RESULT events are emitted only for executed
tools. Rejection results are still written into message history.
2. Emit resolved TOOL_CALL_RESULT events in the no-updates fallback
RUN_STARTED path so approval results are never lost.
3. Rewrite tests to use real FunctionTool with func and
approval_mode='always_require' via StubAgent default_options,
verifying actual tool execution output in TOOL_CALL_RESULT content.
Added test for rejection not emitting TOOL_CALL_RESULT.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix #4589: clean up approval resolution and add missing tests
- Extract duplicated TOOL_CALL_RESULT emission block into
_make_approval_tool_result_events helper to prevent drift
- Remove dead rejection_results construction in _resolve_approval_responses;
_replace_approval_contents_with_results already handles rejections inline
- Pass only approved_results (not all_results) to clarify the contract
- Add mixed approve/reject test validating the core splitting logic
- Add zero-updates test covering the no-updates fallback emission path
- Add direct unit test for _resolve_approval_responses return value
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Apply pre-commit auto-fixes
* Fix import sorting lint error in test_approval_result_event.py
Add blank line between first-party and third-party import groups
to satisfy ruff I001 rule.
Fixes #4589
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 4afc088 commit cefda44
2 files changed
Lines changed: 492 additions & 17 deletions
File tree
- python/packages/ag-ui
- agent_framework_ag_ui
- tests/ag_ui
Lines changed: 42 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
369 | 370 | | |
370 | 371 | | |
371 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
372 | 391 | | |
373 | 392 | | |
374 | 393 | | |
| |||
391 | 410 | | |
392 | 411 | | |
393 | 412 | | |
394 | | - | |
| 413 | + | |
395 | 414 | | |
396 | 415 | | |
397 | 416 | | |
| |||
407 | 426 | | |
408 | 427 | | |
409 | 428 | | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
410 | 435 | | |
411 | 436 | | |
412 | 437 | | |
413 | | - | |
| 438 | + | |
414 | 439 | | |
415 | 440 | | |
416 | 441 | | |
| |||
493 | 518 | | |
494 | 519 | | |
495 | 520 | | |
496 | | - | |
497 | | - | |
| 521 | + | |
| 522 | + | |
498 | 523 | | |
499 | 524 | | |
500 | 525 | | |
501 | 526 | | |
502 | 527 | | |
503 | | - | |
| 528 | + | |
504 | 529 | | |
505 | 530 | | |
506 | 531 | | |
507 | 532 | | |
508 | | - | |
| 533 | + | |
509 | 534 | | |
510 | 535 | | |
511 | 536 | | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
| 537 | + | |
521 | 538 | | |
522 | 539 | | |
523 | 540 | | |
524 | 541 | | |
525 | 542 | | |
526 | 543 | | |
527 | 544 | | |
| 545 | + | |
| 546 | + | |
528 | 547 | | |
529 | 548 | | |
530 | 549 | | |
| |||
787 | 806 | | |
788 | 807 | | |
789 | 808 | | |
790 | | - | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
791 | 812 | | |
792 | 813 | | |
793 | 814 | | |
| |||
851 | 872 | | |
852 | 873 | | |
853 | 874 | | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
854 | 878 | | |
855 | 879 | | |
856 | 880 | | |
| |||
905 | 929 | | |
906 | 930 | | |
907 | 931 | | |
908 | | - | |
| 932 | + | |
| 933 | + | |
909 | 934 | | |
910 | 935 | | |
911 | 936 | | |
| |||
0 commit comments