Python: Fix Azure AI Search citation URLs#6453
Open
eavanvalkenburg wants to merge 3 commits into
Open
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses missing per-document Azure AI Search REST URLs (additional_properties.get_url) on doc_N citation annotations in Foundry streaming responses by enriching citations during final stream aggregation using get_urls data emitted by Azure AI Search output events. It also adjusts Foundry Prompt Agent request preparation to rely on agent_reference (server-resolved model) for first-turn non-preview calls, and adds regression coverage (unit + optional local integration).
Changes:
- Enrich streamed
doc_Ncitation annotations post-stream by correlating them withazure_ai_search_call_outputget_urls. - Suppress “unparsed event” logging / visible content emission for Azure AI Search output events.
- Strip client-side
modelfor first-turn non-preview Prompt Agent calls and add regression tests (plus a local integration check).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| python/packages/openai/tests/openai/test_openai_chat_client.py | Adds unit regression tests for post-stream enrichment and for propagation into mapped AgentResponse. |
| python/packages/openai/agent_framework_openai/_chat_client.py | Adds Azure AI Search output parsing + citation enrichment during streamed response finalization; suppresses logging/visibility for these events. |
| python/packages/foundry/tests/foundry/test_foundry_agent.py | Updates Prompt Agent option-stripping assertions and adds an optional live integration test for Azure AI Search streaming citations. |
| python/packages/foundry/agent_framework_foundry/_agent.py | Strips model for first-turn non-preview Prompt Agent calls so the service resolves model from the agent definition. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 and Context
Fixes #5995.
Fixes #6330.
Azure AI Search citations in Foundry streaming responses can omit
additional_properties.get_urlbecause the per-document URLs arrive in laterazure_ai_search_call_outputstream events instead of on the citation annotation itself.Foundry IQ / MCP search-index citations can also expose only
mcp://searchindex/<document-id>citation URLs even when the MCP retrieval output includes document metadata such as title and source.Description
doc_NURL citation annotations with Azure AI Searchget_urls[]fromazure_ai_search_call_outputevents during final stream aggregation.get_urlalready present on annotations and avoids changing in-progress streaming chunks before the final response.mcp://searchindex/<document-id>citation annotations with MCP retrieval metadata (mcp_document_id,document_title, andsource) when matching document JSON is present in MCP output.ChatResponseand mapped finalAgentResponseenrichment, MCP search-index metadata, plus a local-only Foundry/Azure AI Search integration check that creates and cleans up a temporary Prompt Agent.Contribution Checklist