0%
Building with AI12 min

AI Agents and Tool Use

AI agents are systems where an LLM autonomously decides which actions to take, executes them, observes the results, and iterates — rather than producing a single response to a single prompt.

How agents work

The core agent loop: the LLM receives a goal and a description of available tools. It decides which tool to use and with what parameters. The tool executes and returns results. The LLM receives the results and decides what to do next — either use another tool, or produce a final response. This loop continues until the goal is achieved or a stop condition is hit.

Tool calling

Most frontier models support structured tool calling — the model outputs JSON specifying which tool to call and with what arguments, rather than writing informal text. The application code executes the tool and returns the result. Tools can include: web search, code execution, database queries, API calls, file operations, and custom functions.

When agents are appropriate

Agents make sense for tasks that require multiple steps, where the optimal sequence of steps is not known in advance, and where intermediate results should inform subsequent actions. Research tasks, data analysis pipelines, and multi-step coding tasks are good candidates. Tasks with clear, fixed workflows are better served by deterministic pipelines than agents.

Agent reliability challenges

Agents amplify both model capability and model errors. A hallucinating model that calls tools can produce wrong real-world effects — deleting files, sending emails, executing transactions. Human oversight checkpoints, limited tool permissions, and reversible actions are essential safety design principles for agentic systems.

The reliability bar for agentic systems is much higher than for single-turn applications. An agent that fails one step in five will fail the majority of five-step tasks. Invest in error handling and human-in-the-loop review accordingly.

Check your understanding

3 questions, 70% to pass
1. What distinguishes an AI agent from a single prompt-response?
2. What is structured tool calling?
3. When are agents the appropriate design?