---
title: "The agent loop in thirty lines"
url: https://eldan.ai/tutorials/tool-calling-from-scratch/the-loop
canonical: https://eldan.ai/tutorials/tool-calling-from-scratch/the-loop
locale: en
language: en
updated: 2026-11-23
author: "Eldan Abdrashim"
cite_as: "Eldan Abdrashim. \"The agent loop in thirty lines.\" Eldan.ai, updated 23 November 2026. https://eldan.ai/tutorials/tool-calling-from-scratch/the-loop."
---

# The agent loop in thirty lines

> Write a working agent loop with a step limit and test it with a scripted model.

This lesson is free for newsletter readers. Open https://eldan.ai/tutorials/tool-calling-from-scratch/the-loop, subscribe with your email and confirm the address: the lesson opens in that browser.

## Sources

- [Tool Calling From Scratch](https://eldan.ai/tutorials/tool-calling-from-scratch)
