Question
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?
- A. tool_choice={"required"} Correct
- B. tool_choice={"auto"}
- C. tool_choice={"type":"knowledge_base"}
- D. tool_choice={"type":"mcp"}
Explanation
Setting tool_choice to required gives deterministic behaviour because the model must call a tool, and the agent's knowledge base MCP tool is therefore used when processing the query. The value auto is the behaviour causing the problem, since it lets the model decide whether to call a tool. A knowledge_base type is not a tool_choice value for this scenario. The documented way to make an agent always use the knowledge base MCP tool is required, not a type setting of mcp.