Implement generative AI and agentic solutions 2.2 Build agents by using Foundry

A Foundry agent with several function tools returns two function_call items in one…

Study guide skill: Build agents that integrate retrieval, function-calling, and conversation memory

Question B8-020

A Foundry agent with several function tools returns two function_call items in one response. The app runs only the first function, sends its output, and the agent never completes the task correctly. What should the app do?

Select one answer.

  • A Set tool_choice to none so that the model calls only one function
  • B Send one responses.create call per function result, one after another
  • C Test the agent in the Foundry portal, which runs the function calls automatically
  • D Run each function call in the output array and return all the results in a single responses.create call ✓ Correct answer

Answer: D

When the model decides it needs multiple functions, the app should handle each function call in the output array and return all results in a single responses.create call. tool_choice none stops the model from calling tools at all. The Foundry portal doesn't execute function calls, so testing uses the SDK or REST API.

Deep dive

How it works

With function tools, your app runs the code: the agent returns function_call items, your app executes them, and you send the outputs back so the agent can continue. When the model decides it needs several functions in one response, the function calling page's troubleshooting guidance is:

  1. Handle each function call in the output array.
  2. Return all results in a single responses.create call.

This app runs only the first call and replies, so the agent is missing the second result and can't finish correctly. Also keep an eye on timing: runs expire 10 minutes after creation, so submit tool outputs before then.

Testing has a related limit. The same troubleshooting table says the portal doesn't execute function calls: it shows agents but doesn't invoke functions, so test function calling with the SDK or REST API. The portal also doesn't support adding, removing or updating function definitions.

The other options, and when you'd use them

  • tool_choice none: The model then doesn't call tools at all. That doesn't make it call one function at a time.
  • One responses.create per result: The guidance is all results in a single responses.create call.
  • Test in the portal: The portal doesn't execute function calls. Test with the SDK or REST API.

Exam tip

Multiple function_call items = run them all, then return every output in one responses.create call.

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!