PromptisePromptise
Docs
GitHub
Promptise - AI Framework LogoPromptise

The foundation layer for agentic intelligence. Build, secure and operate autonomous AI systems with Promptise Foundry.

pip install promptise

[01] Foundry

  • MCPcast
  • The Promptise Agent
  • Reasoning Engine
  • MCP
  • Agent Runtime
  • Prompt Engineering
  • Execution Engine
  • Agent Identity

[02] Resources

  • Documentation
  • GitHub
  • Guides
  • Learning Paths
  • Questions

[03] Company

  • About
  • Terms of Service
  • Privacy Policy
  • Cookie Policy
  • Subprocessors

© 2026 Promptise by Manser Ventures. All rights reserved.

Open source · Python

← Guides> Library> Topic

The agent loop: how AI agents run, and how to stop runaway loops

Every AI agent runs a loop. The program sends the model the goal and the conversation so far, the model either answers or asks for a tool call, the program runs the tool and appends the result, and the cycle repeats until the model gives a final answer or a limit is reached.

Most of an agent's behaviour, and most of its failures, come from how this loop is written. Without a step limit or a budget, a model that keeps calling the same tool can run for minutes and spend real money. These guides build the loop from scratch as a ReAct agent, show how to detect an agent that repeats itself without making progress, and set budgets that stop a run before it overspends.

[n.01/02]> 4 guides
  1. 01What Is an AI Agent? Definition, How It Works, ExamplesWhat an AI agent is: a model that calls tools in a loop until a goal is met. How the loop works, a real example, agents vs chatbots and workflows, FAQs.Beginner · 7 minOct 18, 2026
  2. 02AI Agent Stuck in a Loop? How to Detect and Stop ItWhy AI agents get stuck in loops and how to stop them: detect repeated tool calls, cap tool calls per run, and write tool results that end the loop.Intermediate · 18 minOct 18, 2026
  3. 03AI Agent Cost Control: Budgets That Stop Runaway SpendHow to control AI agent costs: per-run and daily budgets that refuse tool calls before they run, token caps, iteration limits, and what each one misses.Intermediate · 18 minOct 18, 2026
  4. 04ReAct Agent From Scratch in Python: The Reason-Act LoopBuild a ReAct agent from scratch in Python: the Thought, Action, Observation loop, a 60-line controller with a real trace, and how it maps to tool calling.Intermediate · 8 minOct 18, 2026
[n.02/02]> go further

Related topics

  • Cost Control9
  • Tool Calling16
  • Agent Runtime7
  • Observability9
  • ReAct4
  • Reliability and Fallbacks6

Topic hubs

  • Cost control and rate limits→
  • Building AI agents in Python→
  • Agent reasoning patterns→
  • Observability and debugging→

By category and level

  • AI Engineering guides71
  • Prompt Engineering guides54
  • Beginner guides36
  • Intermediate guides80

Search every guide.

The library lists all guides with filters for topic, level, category and reading time.

All guidesLearning paths