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.

  • A Set strict to true in the function definition ✓ Correct answer
  • B Set response_format to json_object
  • C Set tool_choice to none
  • D Set parallel_tool_calls to true so the model can retry until the arguments are valid
  • E Set parallel_tool_calls to false ✓ Correct answer

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:

  1. strict: true in the function definition. That single parameter turns structured outputs on for the function.
  2. 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:

Ready to test yourself? The quiz asks this and every other AI-103 question, with instant feedback. Practice this in a quiz →

All Generative AI & agents questions · AI-103 study guide

Thanks for your feedback!