4 Tools in AI agents
This chapter covers
- Tools to interact with external systems in AI agents
- Function calling to invoke APIs, services, and code
- The command-line interface (CLI) for direct environment interaction
- Standard protocols for AI agents
- The model context protocol (MCP) for discoverable tools
Chapters 2 and 3 examined how instructions and external knowledge shape what an LLM knows and how it responds. This chapter focuses on tools, which allow AI agents to act in the external world by invoking APIs, running code, or interacting with files and services. Unlike static context sources, tools affect the context window dynamically, starting with initial tool definitions and expanding with each tool call and execution output. The discussion covers three paradigms for tool use: function calling, the command-line interface (CLI), and the model context protocol (MCP).
4.1 Tools
Tools are a fundamental mechanism for enabling action in LLM-based agents. While a model can reason over text using its internal knowledge and the content of its context window, it has no inherent access to live data, user-specific systems, or the ability to act in the external world. Tools bridge this gap by enabling an AI agent to execute actions and observe their outcomes, with these observations becoming new context that can shape subsequent decisions [29].