LoopAI-103

Before you start

Short explainers for ideas this lesson builds on. Watch these first if they're new to you.

0 of 2 watched · about 4 min

Go deeper

Unlocks when you've watched the lesson.

0 of 1 watched · about 2 min
Read this lesson

Rent it or build it

Tools are what let an agent do things: call an API, run code, search files, or reach another service. Without them, it can only write text from what it already knows. Think of a tool rental shop with a workbench at the back. Some tools are on the rental wall, hosted and run by the provider. Others you build yourself at the bench. With the Foundry provider, the rental wall includes Code Interpreter, which runs Python in a sandbox for calculations and data analysis. File Search looks through uploaded documents, and Web Search finds up-to-date information online. Hosted MCP tools are MCP servers that the provider calls for you. Azure AI Search queries a search index through a Foundry connection. And Foundry toolboxes are named, versioned bundles of hosted tool settings. You switch them on in the agent's configuration, and the provider does the work. Some, like Azure AI Search, Bing grounding, and SharePoint, are still in preview.

Building your own

At the workbench, a custom tool is just a Python function: call an internal API, look something up in a database, do a calculation. Pass the function to the agent when you create it, and the framework reads its signature and writes a schema describing what it does, what it needs, and what it returns. The model can only use a tool well if it's clearly labeled. You can describe each parameter with Annotated and a Field description, and let the docstring describe the whole tool. Or use the tool decorator to set its name and description yourself, with a Pydantic model if you want exact control over the inputs. When the model decides to call a tool, the framework runs your function and hands the result back to the model before it answers. Give the agent a list of functions, and the model picks the right one for each moment, with no routing code from you.

Sign here, and agents as tools

Some tools shouldn't run without a person saying yes: anything that can't be undone, costs money, or touches sensitive data. Set approval_mode on the tool decorator, and the agent pauses and asks before calling it, like a rental counter that wants your signature. You can also hand one agent to another as a tool. Turn the inner agent into a function tool and give it to an outer agent, which can then pass it the jobs it's good at. You'll see much more of that in the multi-agent module.

Labels on the bench

A few habits make custom tools reliable. Write clear descriptions, because the model chooses tools only from what you tell it. Describe every parameter, especially ones whose names don't explain themselves. Return useful, structured data, since the model uses it directly in its answer. Keep each tool focused on one job. And when something goes wrong, return a helpful error message instead of crashing, so the model can still reply sensibly.

Facts from Microsoft's documentation: Microsoft Agent Framework Overview; Agent Framework: tools (CC BY 4.0), rewritten in Loop's own words and examples. Narration, animation, and quiz by Loop. Microsoft, Azure, and Microsoft Foundry are trademarks of Microsoft. Loop is independent and not affiliated with or endorsed by Microsoft.