Skip to content

Python: Fix Azure AI Search citation URLs#6453

Merged
westey-m merged 8 commits into
microsoft:mainfrom
eavanvalkenburg:fix_search_citations
Jun 16, 2026
Merged

Python: Fix Azure AI Search citation URLs#6453
westey-m merged 8 commits into
microsoft:mainfrom
eavanvalkenburg:fix_search_citations

Conversation

@eavanvalkenburg

@eavanvalkenburg eavanvalkenburg commented Jun 10, 2026

Copy link
Copy Markdown
Member

Motivation and Context

Fixes #5995.
Fixes #6330.

Azure AI Search citations in Foundry streaming responses can omit additional_properties.get_url because the per-document URLs arrive in later azure_ai_search_call_output stream 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

  • Correlates streamed doc_N URL citation annotations with Azure AI Search get_urls[] from azure_ai_search_call_output events during final stream aggregation.
  • Preserves any get_url already present on annotations and avoids changing in-progress streaming chunks before the final response.
  • Recognizes Azure AI Search output events so they are not logged as unparsed, while keeping them out of visible response content.
  • Enriches mcp://searchindex/<document-id> citation annotations with MCP retrieval metadata (mcp_document_id, document_title, and source) when matching document JSON is present in MCP output.
  • Strips the client-side model for first-turn non-preview Foundry agent-reference calls so the service resolves the model from the Prompt Agent definition.
  • Adds unit regression coverage for final ChatResponse and mapped final AgentResponse enrichment, 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

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Copilot AI review requested due to automatic review settings June 10, 2026 14:10
@github-actions github-actions Bot changed the title Fix Azure AI Search citation URLs Python: Fix Azure AI Search citation URLs Jun 10, 2026
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/foundry/agent_framework_foundry
   _agent.py2455677%119, 122, 244–245, 249–251, 256–259, 352, 430–431, 443–444, 456–458, 460–461, 463–469, 471–472, 474, 476, 482–484, 487–496, 500–501, 699–700, 703, 729, 739, 755, 825, 830, 834
packages/openai/agent_framework_openai
   _chat_client.py125915887%279, 292, 642–646, 654–657, 663–667, 717–724, 726–728, 735–737, 795, 803, 826, 944, 1043, 1102, 1104, 1106, 1108, 1174, 1188, 1268, 1278, 1283, 1326, 1437–1438, 1453, 1680, 1685, 1689–1691, 1695–1696, 1779, 1789, 1816, 1822, 1832, 1838, 1843, 1849, 1854–1855, 1874, 1877–1880, 1894, 1896, 1904–1905, 1917, 1959, 2024, 2041, 2044, 2071–2073, 2112, 2129, 2132, 2193–2194, 2229, 2267–2268, 2286–2287, 2330, 2496, 2534–2535, 2553, 2636–2644, 2674, 2784, 2819, 2834, 2854–2864, 2877, 2888–2892, 2906, 2920–2931, 2940, 2972–2975, 2985–2987, 2998–3000, 3014–3016, 3026–3027, 3033, 3048
TOTAL39952450888% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
7976 34 💤 0 ❌ 0 🔥 2m 1s ⏱️

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_N citation annotations post-stream by correlating them with azure_ai_search_call_output get_urls.
  • Suppress “unparsed event” logging / visible content emission for Azure AI Search output events.
  • Strip client-side model for 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.

Comment thread python/packages/openai/agent_framework_openai/_chat_client.py
Comment thread python/packages/openai/agent_framework_openai/_chat_client.py Outdated
Comment thread python/packages/openai/agent_framework_openai/_chat_client.py Outdated
Comment thread python/packages/foundry/tests/foundry/test_foundry_agent.py

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 5 | Confidence: 89% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Failure Modes, Design Approach


Automated review by eavanvalkenburg's agents

Comment thread python/packages/openai/agent_framework_openai/_chat_client.py
Comment thread python/packages/foundry/agent_framework_foundry/_agent.py Outdated
eavanvalkenburg and others added 3 commits June 15, 2026 14:34
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@moonbox3 moonbox3 added this pull request to the merge queue Jun 15, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 15, 2026
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Jun 16, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 16, 2026
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Jun 16, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 16, 2026
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Jun 16, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 16, 2026
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Jun 16, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 16, 2026
@westey-m westey-m enabled auto-merge June 16, 2026 13:29
@westey-m westey-m added this pull request to the merge queue Jun 16, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 16, 2026
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Jun 16, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Jun 16, 2026
@westey-m westey-m merged commit 571cae4 into microsoft:main Jun 16, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

5 participants