Implement generative AI and agentic solutions 2.1 Build generative applications by using Foundry

A finance agent in Foundry Agent Service must calculate exact quarter-over-quarter growth…

Study guide skill: Design workflows, tool-augmented flows, and multistep reasoning pipelines

Question B3-013

A finance agent in Foundry Agent Service must calculate exact quarter-over-quarter growth from a CSV file that the user uploads and return a bar chart image that the app can download. The team doesn't want to build or host its own calculation service. Which tool should you give the agent?

Select one answer.

  • A Code Interpreter, with the uploaded CSV made available to it ✓ Correct answer
  • B A function tool that calls a calculation API
  • C Code Interpreter, but have the model describe the chart in text, because Code Interpreter can't return generated files
  • D The file search tool

Answer: A

Code Interpreter lets the agent write and run Python in a sandbox, iterating on data analysis and math and generating charts as downloadable files. The file search tool parses, chunks, and embeds documents for retrieval, so it can't run calculations. With a function tool, your own application has to execute the function, which means building the calculation service, and Code Interpreter can return generated files such as charts for the app to download.

Deep dive

How it works

Code Interpreter lets a Foundry agent run Python in a sandboxed execution environment. The agent's model writes and runs code for data analysis, chart generation and iterative problem-solving, and it can keep iterating until a data analysis or math task is solved. The documented walkthrough matches this scenario almost step for step: create an agent with Code Interpreter, upload a CSV file for analysis, ask for a bar chart, and download the generated chart. The calculations happen in code, not in the model's head, and you don't build or host any service for them.

A few operational details are worth knowing. Code Interpreter has charges on top of the token-based fees. If the agent calls it in two conversations at the same time, it creates two Code Interpreter sessions. Each session is active for one hour by default, with a 30-minute idle timeout. Code Interpreter isn't available in every region, so check regional and model availability before you design around it.

The other options, and when you'd use them

  • A function tool that calls a calculation API: With function calling, the model asks your app to call the function. Your app runs it and returns the output, which is why you'd have to build the calculation service. Runs expire 10 minutes after creation, so submit tool outputs before then. Use function tools when the agent needs real-time data or actions from your own systems.
  • Code Interpreter, but describe the chart in text: There's no need. The documented flow uploads a file, asks for a chart and downloads the generated chart as a file.
  • The file search tool: File search parses, chunks and embeds documents so they can be retrieved with keyword and semantic search. Use it to ground answers in documents. It retrieves passages and doesn't run calculations.

Exam tip

"Exact math on an uploaded file, plus a chart to download, with nothing to host" means Code Interpreter. "Call our own system" means a function tool, and "answer from documents" means file search.

References

Microsoft Learn 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!