Forcing Tool Invocation in Microsoft Foundry Agents
You have a Microsoft Foundry project that contains an agent. The agent has a Model Context Protocol (MCP) tool named kbsearch 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 deterministically force the agent to invoke kbsearch on each run.
What should you do?
Community Insight
Tests knowledge of agent execution parameters; the trap is confusing output formatting or thread management with tool selection logic.
This question addresses how to ensure a Microsoft Foundry agent deterministically invokes specific tools like kbsearch. It establishes that the tool_choice parameter is the correct configuration for this requirement.
Learners often select response_format, mistakenly believing it controls which tools are used rather than just the structure of the final output.
Community Discussion (1 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
The core issue is that the agent sometimes relies on its base model's internal knowledge instead of using the provided kbsearch tool. To fix this and ensure grounded citations, you must explicitly instruct the agent to use the tool. Thetool_choice parameter allows you to specify exactly which tool(s) the agent should invoke. Setting tool_choice to kbsearch forces the agent to call this tool on every run, satisfying the requirement for deterministic behavior.Why the Other Options Are Wrong
Option A (response_format) only dictates the format of the response (e.g., JSON vs. text) and does not influence tool selection. Option B (create_thread_and_process_run) changes the concurrency model but does not enforce tool usage. Option C (toolset) defines the available tools but does not force their invocation; withouttool_choice, the agent still decides whether to use them.Community Comment Notes
Community consensus strongly supports option D, with users noting that "The tool_choice parameter lets you explicitly force the agent to use a specific tool." This aligns with standard LLM orchestration patterns where explicit tool forcing is required for grounding.Exam Strategy
When configuring agents, distinguish between defining capabilities (tools) and enforcing behaviors (tool_choice). If the exam asks for deterministic tool usage, look for parameters that override the model's natural routing decisions.
Frequently Asked Questions
Why doesn't adding the tool to the toolset force its use?
The toolset parameter only makes the tool available to the agent. Without tool_choice, the LLM can still decide not to call it if it believes it knows the answer.
What is the difference between tool_choice and response_format?
response_format controls how the final answer is structured (e.g., JSON schema), while tool_choice controls which external functions the agent is allowed or forced to execute.
Related Analysis
Practice All AI-103 Questions
Access 88 questions with complete answers and detailed explanations.
View Full AI-103 Practice Test →