A fully managed platform in Microsoft Foundry for hosting, scaling, and securing AI agents built with any supported framework or model
Hello @Brenda Griggs
Thank you for reaching out and for providing a detailed explanation of your observations.
From your description, I understand that you're trying to determine whether there's a deterministic relationship between the inline citation references (for example, ref_id:0, ref_id:1) and the metadata returned by the knowledge_base_retrieve MCP tool (such as id and document_id), similar to the structured ChatMessageContext.Citations object that was available with Azure OpenAI On Your Data.
After reviewing the current Azure AI Foundry documentation and SDK behavior, there is currently no officially documented or supported mapping that explains how the following elements relate to one another:
- Inline citation markers (for example,
【message_idx:search_idx†source】) - Inline references such as
ref_id:0,ref_id:1 - The retrieved source metadata (
id,document_id, and other chunk information)
Although these values may appear to correlate in some responses, Microsoft has not published a contract that defines a deterministic relationship between them. Therefore, assumptions such as:
-
ref_idcorresponding directly tosearch_idx - A fixed offset (for example,
ref_id + 1 = search_idx) - Any other arithmetic relationship
should not be relied upon, as the numbering appears to be an implementation detail rather than a supported API contract and may change in future service updates.
From the current documentation, what is documented is the overall retrieval pipeline used by Foundry Agent Service when working with a Knowledge Base. The service:
- Plans and decomposes the user query.
- Retrieves relevant content using keyword, vector, or hybrid search.
- Applies reranking to the retrieved results.
- Synthesizes the final response with source references.
However, the documentation does not describe how the internal numbering (ref_id, search_idx, or message_idx) is generated, nor does it document an equivalent to the ChatMessageContext.Citations collection that exposes structured citation metadata for each individual citation.
This differs from the Azure OpenAI On Your Data experience, where applications could directly consume structured citation information such as content, title, filepath, URL, and other metadata without having to interpret inline markers.
If your application requires deterministic traceability between an answer and the exact source chunk that was retrieved, we recommend relying on the structured output returned by the knowledge_base_retrieve tool rather than attempting to parse or infer relationships from the inline citation markers. The retrieved documents include identifiers such as document_id and chunk id, which are intended for programmatic processing, whereas the inline citation markers are primarily designed for presentation within the generated response.
Since the citation numbering itself isn't currently documented, the recommended approach for understanding the retrieval and grounding process is to use Azure AI Foundry Tracing.
By enabling tracing, you can inspect the complete execution flow, including:
- Query planning
- Tool invocations
- Retrieval operations
- Intermediate processing steps
- Final answer synthesis
While tracing does not currently provide a direct mapping between each inline citation marker and its corresponding source chunk, it is the supported mechanism for understanding the retrieval pipeline and diagnosing grounding behavior end-to-end.
Please refer this
ChatMessageContext.Citations Property
Set up tracing in Microsoft Foundry
https://learn.microsoft.com/azure/ai-foundry/observability/how-to/trace-agent-setup?view=foundry https://learn.microsoft.com/azure/ai-foundry/observability/how-to/trace-agent-framework?view=foundry
Connect a Foundry IQ knowledge base to Foundry Agent Service (MCP pipeline, source references, API version note): https://learn.microsoft.com/azure/foundry/agents/how-to/foundry-iq-connect?wt.mc_id=knowledgesearch_inproduct_azure-cxp-community-insider
(Classic example of structured citations as message annotations) Grounding with Bing Custom Search (preview) (classic): https://learn.microsoft.com/azure/foundry-classic/agents/how-to/tools-classic/bing-custom-search?wt.mc_id=knowledgesearch_inproduct_azure-cxp-community-insider#understand-citations-in-the-agent-response
I Hope this helps. Do let me know if you have any further queries.
If this answers your query, please do click Accept Answer and Yes for was this answer helpful.
Thank you!