Deterministically Force MCP Tool Invocation in Microsoft Foundry
You have a Microsoft Foundry project that contains an agent. The agent has a Model Context Protocol (MCP) tool that queries a knowledge base stored in Azure AI Search.
Some agent runs return answers from the base model without invoking the knowledge base, which results in responses without grounded citations.
You are provided with the following code snippet that runs the agent.
You need to add the correct tool _choice parameter to the code to deterministically force the agent to invoke the MCP tool on each run.
What should you add?
Community Insight
The exam tests the distinction between forcing any tool usage versus forcing a specific tool type, with the common trap being the selection of 'required' which does not guarantee the correct tool is used if multiple tools are present.
This question examines how to configure the tool_choice parameter in Microsoft Foundry agents to ensure deterministic invocation of a specific Model Context Protocol (MCP) tool. It clarifies that specifying the tool type is required to prevent the base model from answering without grounding.
Many learners choose 'required' because it forces tool usage, but they fail to realize that 'required' allows the agent to pick any available tool, whereas the question demands the specific MCP tool be invoked.
Community Discussion (13 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
The correct option is D:tool_choice={"type":"mcp"}. The question explicitly asks to "deterministically force the agent to invoke the MCP tool." In the Azure OpenAI API and Microsoft Foundry context, setting tool_choice to an object with a type property binds the call to tools of that specific type. Since the MCP tool is defined by its type, this ensures the agent calls the knowledge base retrieval tool rather than relying on internal knowledge.Why the Other Options Are Wrong
Option A ({"required"} or similar syntax) forces the model to call a tool, but if multiple tools were registered, the agent might choose one other than the MCP tool. Option B ({"auto"}) allows the model to decide whether to use a tool, which leads to the problem described (skipping the KB). Option C uses a non-standard value knowledge_base which is not a valid tool type identifier in the underlying API schema.Community Comment Notes
Several users correctly identified that 'required' is insufficient for deterministic targeting of a specific tool. As user Sky_Akash noted, "{\"required\"} only ensures some tool is used, not specifically the MCP tool." User Mattt also highlighted that D is more precise because it explicitly targets the MCP type, whereas A is generic. Some users pointed out syntax nuances, but the semantic requirement of 'deterministic' invocation points to D.Exam Strategy
Always read the keyword 'deterministically' or 'specifically' in agent configuration questions. If the goal is to target a specific capability (like search or code execution), look for options that specify the tool type or name, not just 'required'.
Frequently Asked Questions
Why isn't tool_choice="required" sufficient?
Because 'required' only forces the use of any tool. If multiple tools exist, the agent could pick the wrong one. The question requires the specific MCP tool.
What does deterministically mean here?
It means the outcome is predictable and fixed. Using the tool type ensures the exact same tool is called every time, preventing the base model from skipping it.
Related Analysis
Practice All AI-103 Questions
Access 88 questions with complete answers and detailed explanations.
View Full AI-103 Practice Test →