Repository navigation
Python: Preserve AG-UI citations through client and agent streaming - #9094
Open
quifox (quifox) wants to merge 3 commits into
Open
quifox (quifox) wants to merge 3 commits into
quifox (quifox) wants to merge 3 commits into
Conversation
Keep late annotations attached to their message through function-loop and mapped-agent aggregation. Preserve response metadata and buffered middleware output, with regression coverage for both public response paths.
quifox (quifox)
temporarily deployed
to
github-app-auth
October 5, 2026 23:29 — with
GitHub Actions
Inactive
quifox (quifox)
temporarily deployed
to
github-app-auth
October 5, 2026 23:29 — with
GitHub Actions
Inactive
quifox (quifox)
marked this pull request as ready for review
October 5, 2026 23:30
quifox (quifox)
temporarily deployed
to
github-app-auth
October 5, 2026 23:31 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The scoped aggregation changes preserve existing fallback behavior and are covered across the affected streaming paths.
Review effort: Balanced
Findings: None
What changed in this PR
Preserves late AG-UI citations across client, tool-loop, and agent streaming aggregation without creating duplicate messages.
Changes:
- Adds private whole-loop and agent-level finalization hooks.
- Applies annotation-aware aggregation at AG-UI streaming boundaries.
- Adds regression coverage for metadata, tools, structured output, and middleware.
| File | Description |
|---|---|
python/packages/core/agent_framework/_tools.py |
Adds whole-loop finalization hook. |
python/packages/core/agent_framework/_clients.py |
Adds mapped-agent finalization hook. |
python/packages/core/agent_framework/_agents.py |
Delegates default agent aggregation to compatible clients. |
python/packages/ag-ui/agent_framework_ag_ui/_event_converters.py |
Generalizes annotation-aware aggregation for chat and agent responses. |
python/packages/ag-ui/agent_framework_ag_ui/_client.py |
Implements AG-UI-specific finalization hooks. |
python/packages/core/tests/core/test_function_invocation_logic.py |
Tests whole-loop metadata and structured output. |
python/packages/core/tests/core/test_agents.py |
Tests client and agent extension-point precedence. |
python/packages/ag-ui/tests/ag_ui/test_event_converters.py |
Tests annotation-only metadata aggregation. |
python/packages/ag-ui/tests/ag_ui/test_ag_ui_client.py |
Adds public-path citation regressions. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
quifox (quifox)
temporarily deployed
to
github-app-auth
October 7, 2026 01:14 — with
GitHub Actions
Inactive
quifox (quifox)
temporarily deployed
to
github-app-auth
October 7, 2026 15:26 — with
GitHub Actions
Inactive
quifox (quifox)
temporarily deployed
to
github-app-auth
October 7, 2026 15:33 — with
GitHub Actions
Inactive
This branch was previously deployed
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.
Motivation & Context
Late AG-UI citations can create an empty duplicate message in the default public streaming response instead of attaching to the earlier text. For example, m1/First followed by m2/Second and a citation for m1 becomes three messages, with the citation on the empty duplicate m1.
This remains after #8948 because the function-invocation stream and the mapped Agent.run stream each aggregate updates outside the AG-UI inner finalizer. Non-streaming controls preserve the expected two messages.
Description & Review Guide
Related Issue
Fixes #9093
Follow-up to #8948, covering the remaining whole-loop and mapped-agent aggregation paths. The linked issue requests review of the private core extension points.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.The unit-test item remains unchecked because validation covers the affected modules; the full workspace matrix is left to CI.