Python: fix AG-UI pending tool history replay - #5973
Closed
Yufeng He (he-yufeng) wants to merge 1 commit into
Closed
Python: fix AG-UI pending tool history replay#5973Yufeng He (he-yufeng) wants to merge 1 commit into
Yufeng He (he-yufeng) wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR fixes AG-UI replay edge cases by ensuring pending assistant tool calls are proactively closed (via synthetic tool results) before subsequent assistant messages and at the end of replayed history.
Changes:
- Inject synthetic tool results when a new assistant message arrives while tool calls are still pending.
- Inject synthetic tool results when replayed history ends with pending tool calls.
- Add tests covering “assistant-before-next-assistant” and “end-of-history” pending tool-call scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| python/packages/ag-ui/agent_framework_ag_ui/_message_adapters.py | Adds a helper to flush pending tool calls and extends sanitization to handle pending calls before the next assistant message and at end-of-history. |
| python/packages/ag-ui/tests/ag_ui/test_message_adapters.py | Adds regression tests for the new pending-tool-call sanitization behavior. |
| def flush_pending_tool_results(result: str) -> None: | ||
| nonlocal pending_confirm_changes_id, pending_tool_call_ids | ||
|
|
||
| if not pending_tool_call_ids: |
Contributor
There was a problem hiding this comment.
Let's address this one, please.
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
Contributor
|
Please re-open if you decide to take this forward. Closing due to inactivity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
To verify
uv run pytest packages/ag-ui/tests/ag_ui/test_message_adapters.py -q -p no:cacheprovideruv run pytest packages/ag-ui/tests/ag_ui/test_message_adapters.py packages/ag-ui/tests/ag_ui/test_agent_wrapper_comprehensive.py -q -p no:cacheprovideruv run ruff check packages/ag-ui/agent_framework_ag_ui/_message_adapters.py packages/ag-ui/tests/ag_ui/test_message_adapters.pyuv run mypy --config-file packages/ag-ui/pyproject.toml packages/ag-ui/agent_framework_ag_ui/_message_adapters.pygit diff --checkFixes #5855