Implement generative AI and agentic solutions 2.2 Build agents by using Foundry
A model calls a create_refund function through the Chat Completions API.
Study guide skill: Define agent roles, goals, conversation-tracking approach, and tool schemas
Question B3-015
A model calls a create_refund function through the Chat Completions API. The function's arguments must always conform exactly to its JSON Schema. Which two settings should you use? (Choose two.)
Select 2 answers.
Answer: A, E
Structured outputs for function calling are enabled by setting strict to true in the function definition, and because structured outputs aren't supported with parallel function calls, you set parallel_tool_calls to false. JSON mode (json_object) guarantees valid JSON but not adherence to your schema. Setting tool_choice to none forces a user-facing message, so the model wouldn't call the function at all.
Deep dive
How it works
Function calling lets the model return arguments for your functions. To guarantee those arguments always match the function's JSON Schema, you use structured outputs for function calling, which takes two settings:
- strict: true in the function definition. That single parameter turns structured outputs on for the function.
- parallel_tool_calls: false on the request. Structured outputs aren't supported with parallel function calls, so the structured outputs page tells you to set it to false.
Structured outputs constrain the model to your schema. Microsoft contrasts this with the older JSON mode, which guaranteed valid JSON but couldn't ensure strict adherence to the supplied schema.
The other options, and when you'd use them
- response_format json_object: That's JSON mode. It guarantees valid JSON but not that the output matches your schema.
- tool_choice none: It forces a user-facing message, so the model wouldn't call create_refund at all. The default, auto, lets the model decide whether and which function to call.
- parallel_tool_calls true: Structured outputs don't support parallel function calls, so this works against the guarantee instead of helping it.
Exam tip
Schema-exact function arguments = strict: true + parallel_tool_calls: false. JSON mode = valid JSON only.
References
Last reviewed: