Implement generative AI and agentic solutions 2.2 Build agents by using Foundry
You add a get_order_status function definition to a chat completions request, and the…
Study guide skill: Build agents that integrate retrieval, function-calling, and conversation memory
Question B1-017
You add a get_order_status function definition to a chat completions request, and the model responds with a tool call. What happens next?
Select one answer.
Answer: D
With function calling, the model only generates the function name and structured arguments. Your application executes the function and returns the result to the model, so you stay in control of the actions taken. The service doesn't execute your code or call your endpoints for you.
Deep dive
How it works
With function calling, you describe functions in the request's tools parameter, and the model decides from the prompt's context whether to call any of them. When it does, it returns a JSON object with the arguments. The model generates the function call and its structured arguments, and your application executes the function and returns the result, so you stay in control of the actions taken.
The loop has three steps:
- Call the Chat Completions API with your functions and the user's input.
- Use the model's response to call your API or function.
- Call the Chat Completions API again with your function's result to get a final response.
In the follow-up request, you append the assistant message that contains the tool call, then add a message with role set to tool and a tool_call_id that matches the call's id. With parallel function calling, one response can hold several tool calls, each with its own id, and you answer each one with its own message.
The other options, and when you'd use them
- The call is ignored unless tool_choice is none: It's the opposite.
tool_choiceset tononeforces a user-facing message instead of a tool call. The default,auto, lets the model decide whether to call a function and which one, and you can name a specific tool to force that call. - The service runs the function in a sandbox: That describes Code Interpreter, an agent tool that runs Python code the model writes in a sandboxed environment. That's a different tool from function calling, where your app runs the function.
- Azure OpenAI calls your HTTP endpoint automatically: In Chat Completions function calling, your application runs the function and sends the result back. That's what keeps you in control of the actions taken.
Exam tip
The model proposes and your app executes. In Chat Completions, use tools and tool_choice. The older functions and function_call parameters are deprecated.
References
Last reviewed: