.NET: Preserve streamed annotations in Foundry hosted responses - #7984
.NET: Preserve streamed annotations in Foundry hosted responses#7984Roger Barreto (rogerbarreto) wants to merge 2 commits into
Conversation
Capture annotations delivered separately from text and emit supported citation types through hosted Responses streams. Add local and live streaming and non-streaming coverage for web search and Azure AI Search. Copilot-Session: 0c67da26-d12e-47ab-aac4-53e251ef6edf
There was a problem hiding this comment.
Pull request overview
Preserves Foundry citation annotations across streaming and completed Responses payloads.
Changes:
- Correlates annotation-only updates and deduplicates citations.
- Maps URL, file, path, and container citations.
- Adds unit, HTTP, and hosted integration coverage.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
OutputConverter.cs |
Preserves and maps annotations. |
OutputConverterTests.cs |
Tests conversion and deduplication. |
AgentFrameworkResponseHandlerTests.cs |
Tests handler propagation. |
HostedAnnotationsTests.cs |
Tests HTTP response serialization. |
Microsoft.Agents.AI.Foundry.Hosting.UnitTests.csproj |
Adds SSE parser dependency. |
WebSearchAnnotationsHostedAgentTests.cs |
Tests hosted web citations. |
AzureSearchToolAnnotationsHostedAgentTests.cs |
Tests Search citations. |
WebSearchAnnotationsHostedAgentFixture.cs |
Configures web-search scenario. |
AzureSearchToolAnnotationsHostedAgentFixture.cs |
Configures Search scenario. |
Program.cs |
Adds annotation test agents. |
TestSettings.cs |
Adds Search connection settings. |
it-bootstrap-agents.ps1 |
Bootstraps new scenarios. |
README.md |
Documents setup and RBAC. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): 8690a70c5e0d
Model: gpt-5.6-sol
Overview
The change correlates late annotation-only content with an open streamed message, maps the supported citation shapes, suppresses exact duplicates, and emits annotations in the required completion order. Unit, handler, HTTP, and live integration coverage exercise the principal Foundry paths and reject mismatched IDs. One provider-compatibility gap remains for valid streams where message IDs are absent throughout.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
1 verified finding remained after source verification (1 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: dotnet/src/Microsoft.Agents.AI.Foundry.Hosting/OutputConverter.cs
Copilot-Session: 0c67da26-d12e-47ab-aac4-53e251ef6edf
There was a problem hiding this comment.
MAF Automated Review — Iteration 2
Result: No findings
Scope: 1 net-new commit(s): ea91a4e61a86
Model: gpt-5.6-sol
Overview
This incremental update strengthens late-annotation correlation by resolving message IDs from the underlying OpenAI streaming events while retaining guards against attaching unknown annotations to a known open message. Focused converter, handler, HTTP, and live integration coverage exercises missing IDs, mismatched IDs, duplicate citations, supported citation shapes, event ordering, and final payload preservation. No publishable Critical, High, or Medium defect is established on a changed line in the authoritative incremental range.
Reviewed the supplied incremental change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
Motivation & Context
Foundry hosted agents can receive citation annotations separately from streamed text updates. The OpenAI Responses adapter surfaces the completed annotation set in an annotation-only
AIContent, butOutputConverteronly collected annotations attached directly toTextContent. Hosted clients therefore received citation markers withoutresponse.output_text.annotation.addedevents or annotation metadata in completed payloads.Description & Review Guide
Related Issue
Fixes #6926
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.