HeadlinesBriefing HeadlinesBriefing.com

Build Your First AI Agent with One Tool Call

Towards Data Science •
×

If you work with software development, AI, and Large Language Models (LLMs), you likely use AI agents regularly. This article shows you how to build your first one. Before building, it's worth defining the term. There are many answers, but most agree that an AI agent is a software system that uses an LLM that calls one or more tools in a loop to reach a goal. That goal can range from answering a simple question to controlling your browser to book an airline ticket or developing complex software.

In agentic systems, the loop describes the cycle between the model, the application and its tools. It doesn't require a literal while or for statement. The example here makes one pass through that cycle: the model requests a tool, Python runs it, and the model uses the result to answer. The agent won't do anything complex, by design, to keep things simple to begin with.

The example is a support assistant for a fictional online shop. Order data sits in a SQLite database, so a language model can't answer order questions on its own. Instead, the model requests a Python function called get_order_total, which queries the database and returns the real value. For order 1001 for Sarah Jones, the correct total is GBP 96.95.

The model can ask for an operation, but Python decides whether it's allowed and performs it. The model runs locally through Ollama, so no cloud account or API key is needed. The program prints the requested function, its arguments and the database result, making the exchange visible rather than hidden inside an agent framework.

Source: Towards Data Science · Summarized by HeadlinesBriefing