A unified Azure platform for creating and managing AI models, agents, and applications with built‑in enterprise security, monitoring, and governance
Hi @Nimesh , thanks for posting your issue here.
This is a fundamental limitation of RAG based search and not a bug. When you ask "show me tickets with keyword X for month Y", the KB retrieves relevant text chunks and the model answers from them. But when you ask "how many tickets were received in month Y", the agent would need to count every matching row across your entire Excel file, and RAG only retrieves the top K most semantically relevant chunks, not all records. So the count will almost always be wrong or incomplete.
The right fix here depends on what you need:
- Option 1: Code Interpreter (quickest for PoC) Upload the Excel file directly to the agent session and enable Code Interpreter. The agent can then run actual Python/pandas over the full dataset and give you exact counts and aggregations. The downside is files need to be re-uploaded per session, so it's not great for live production data.
- Option 2: Custom API Tool (recommended for production) Expose a small endpoint from your backend that queries the data source directly and returns counts. Something like
/ticket-count?month=2026-05. Register it as an OpenAPI tool in Foundry and the agent will call it automatically when it detects an aggregation question. This is the cleanest approach and scales well. - Option 3: Pre-aggregate in the index If the data doesn't change often, pre-compute the monthly counts and store them as separate documents in your Azure AI Search index. The agent can then retrieve them directly. Simple but only works if near-realtime accuracy isn't needed.
I'd go with Option 2 if this is heading toward production, and Option 1 if you just need to demo it quickly.
Please upvote and accept the answer if it helps!