Inside an AI agent: seven tools that turn an LLM into an executor
What happens when a language model gets access to a terminal, a file system, and the internet? That is exactly how Claude Code and Codex work: the agent reads code on its own, edits files, and runs commands. In the second part of the tutorial, we cover seven core tools and the selection mechanism: how the model decides which tool to invoke in each situation.
AI-processed from Habr AI; edited by Hamidun News
If you give a language model a terminal, file system, and internet access, it stops being a chatty assistant and turns into an agent — this is how Claude Code, Codex, and other developer tools work under the hood. The second part of the tutorial explains how to add seven basic tools to a model and teach it to independently choose the right one depending on the task.
What are agent tools
A language model by itself can only do one thing — generate text based on input context. To become an agent, it needs tools: specific functions that the agent framework executes on the model's command and returns the result back to the context. The principle is simple: the model receives a prompt with descriptions of available tools — name, parameters, what it does. While working, it evaluates the task and decides on its own whether something needs to be called, and if so — what exactly and with what arguments. The developer defines the set of available functions; choosing the specific tool for a specific situation is up to the model.
In the tutorial, the agent is given seven basic tools:
- Reading files from the file system
- Writing and editing files
- Executing commands in the terminal
- Navigating directories and listing contents
- Running Python scripts on the fly
- Searching for information on the internet
- Getting information about the system and environment
This set already allows the agent to independently read other people's code, make edits, run tests and check their results — without human involvement at every step.
How the model chooses a tool
The key moment is not the tool set itself, but the selection mechanism. This is called tool calling or function calling, and this is where modern LLMs fundamentally differ from chatbots of the previous generation. When a model decides that a tool is needed for a task, it returns not just text, but structured JSON: function name and arguments. The agent framework intercepts this JSON, executes the actual operation — runs a command, reads a file, makes an HTTP request — and returns the result back to the context. The model looks at the result, thinks again, and either calls the next tool or finishes the work.
This loop — think, call a tool, get a result, think again — is what turns a static language model into a dynamic system. At the same time, the model doesn't follow a rigid script: each time it re-analyzes the situation taking into account all accumulated context — previous steps, intermediate results, original task. This is what makes the agent flexible: it can correct the plan on the fly if an intermediate result turns out unexpected.
The loop and the stopping problem
The agent works in a cycle: generates a response → if a tool is needed, calls it → gets a result → generates again. The cycle continues until the task is completed or the agent decides that further calls are not needed. Here lies the main engineering complexity: how does the model understand that it's time to complete the loop?
In simple implementations, one of two approaches is used. First — iteration limit: if after N steps the task is not completed, the agent is forcibly stopped. Second — special completion signal: the model returns a "done" marker, and the framework exits the loop.
Claude Code and Codex solve this much more sophisticatedly: taking into account the task context, the cost of each call, and analysis of intermediate results. But the fundamental principle is the same — a loop with an explicit exit condition. This condition determines whether the agent will be a useful tool or hang in an infinite loop.
What this means
The tutorial clearly shows: the difference between a simple chatbot and a powerful tool like Claude Code — is not in the size of the model and not in magic, but in architecture. Add a loop, several functions and a stopping rule — you get a system that can work with the real world: read code, edit files, run tests and search for information on the web. This is what makes modern AI agents practically useful for developers, rather than just impressive in demos.
Want to stop reading about AI and start using it?
AI News is a curated feed of AI/tech news. Hamidun Academy teaches you to use AI systematically in your work.
The AI world, distilled — once a week
Seven stories that actually mattered, hand-picked. No noise, no reposts, no press releases.
Done! Check your inbox for a confirmation.