Python: Add include_reference_source_data to agentic search requests - #5100
Conversation
|
Matt Van Horn (@mvanhorn) some tests and check failures, please have a look |
|
Took a look - the 6 failing tests are all in |
|
then ensure you are working against the latest main |
9ab5ee2 to
d1fd0a8
Compare
|
Eduard van Valkenburg (@eavanvalkenburg) rebased onto latest main in d1fd0a8. The |
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
23afd3e to
13d25a0
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the Python Azure AI Search AzureAISearchContextProvider agentic retrieval request construction so that reference source_data can be returned by opting in via knowledge_source_params (include_reference_source_data=True). It also adds unit tests to validate the request includes these parameters for both minimal and non-minimal reasoning effort paths.
Changes:
- Add
KnowledgeSourceParams(..., include_reference_source_data=True)to bothKnowledgeBaseRetrievalRequestcode paths in_agentic_search(). - Add
KnowledgeSourceParamsto the type-checking and runtime import blocks. - Add unit tests asserting
knowledge_source_paramsis present for minimal and non-minimal reasoning effort requests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
python/packages/azure-ai-search/agent_framework_azure_ai_search/_context_provider.py |
Injects knowledge_source_params into agentic retrieval requests so reference source_data can be returned. |
python/packages/azure-ai-search/tests/test_aisearch_context_provider.py |
Adds tests verifying knowledge_source_params is set for both reasoning-effort branches. |
|
Please address or resolve the comments from Copilot if they are valid. |
Head branch was pushed to by a user without write access
|
Good catch from Copilot, both comments were valid. Fixed in cee7874: in agentic mode against an existing Knowledge Base, |
|
Can you resolve the comments by Copilot, if no longer needed/applicable, please? |
|
Matt Van Horn (@mvanhorn) there are some failing tests and some open comments, please have a look, so we can get this fixed. |
Add an optional keyword-only `knowledge_source_params` to the agentic overloads of `AzureAISearchContextProvider`, forwarded verbatim into both `KnowledgeBaseRetrievalRequest` constructions in `_agentic_search`. This lets callers set per-source agentic retrieval options such as `filter_add_on` (OData filtering), `include_reference_source_data`, and similar. Default `None` keeps existing behavior unchanged. The parameter is agentic-only: it is omitted from the semantic overload (a type-level contract) and a runtime ValueError guards untyped callers that pass it in semantic mode. Superset of microsoft#5095 / microsoft#5100. Refs microsoft#5560
|
Both Copilot comments were valid and are fixed in cee7874 — in agentic mode against an existing Knowledge Base, index_name is forced to None, so the source name no longer resolves to "None-source". I've resolved those two threads since they're now addressed. On the failing tests: the checks I can see here (license/cla, add_label) are green — I think the Python test workflow needs a maintainer to approve/re-run it on this fork PR. Could you kick that off, or point me at a specific failure and I'll dig in right away? |
|
Matt Van Horn (@mvanhorn) can you please have a look at the conflict as well? |
7bb26fd to
283cb51
Compare
|
Rebased onto main. The conflict was in Ran the azure-ai-search tests: 129 pass with the preview SDK (12.1.0b1); on GA 12.0.0 everything passes except the one preview-only messages test (which needs the preview request shape), as expected. ruff clean. |
|
Hi Matt Van Horn (@mvanhorn), still seeing a lot of CI/CD test failures. |
Pass knowledge_source_params with include_reference_source_data=True for each resolved knowledge source on the KnowledgeBaseRetrievalRequest, so ref.source_data is populated when the source has source_data_fields configured. Uses SearchIndexKnowledgeSourceParams (azure-search-documents 12.0.0) and resolves real source names for both created and existing knowledge bases (avoids the prior 'None-source' name). Fixes microsoft#5095
f3fe8ed to
9f8f2fc
Compare
|
Rebased onto main and reworked this for the |
Evan Mattson (moonbox3)
left a comment
There was a problem hiding this comment.
Thanks for helping see this through, Matt Van Horn (@mvanhorn)
|
Thanks for shepherding this through, Evan Mattson (@moonbox3) - include_reference_source_data rounds out the agentic search response. |
|
Appreciate the review and merge, Evan Mattson (@moonbox3)! include_reference_source_data on agentic search should help folks trace citations. |
Summary
_agentic_search()inAzureAISearchContextProviderconstructsKnowledgeBaseRetrievalRequestwithout passingknowledge_source_params, soinclude_reference_source_datais never set. This causesref.source_datato always beNoneon returned references, even when the knowledge source hassource_data_fieldsconfigured.Changes
knowledge_source_params=[KnowledgeSourceParams(..., include_reference_source_data=True)]to bothKnowledgeBaseRetrievalRequestconstructions in_agentic_search()(the minimal reasoning path at line 828 and the non-minimal path at line 836)KnowledgeSourceParamsto bothTYPE_CHECKINGand runtime import blocksTesting
knowledge_source_paramsis present with correctknowledge_source_nameandinclude_reference_source_data=Truefor both the minimal and non-minimal reasoning pathsFixes #5095
This contribution was developed with AI assistance (Claude Code).