PromptisePromptise
PlatformSoonEnterprise
DocsGitHub
Talk to usGet started
Promptise - AI Framework LogoPromptise

The full-stack framework for agentic systems. Build with the framework. Run it on the platform. Launch it with our engineers.

pip install promptise

[01] Product

  • Framework
  • Platform (coming soon)
  • Enterprise
  • How it works
  • Contact

[02] Framework

  • The Agent
  • The Interface
  • The Harness

[03] Resources

  • Documentation
  • GitHub
  • Why Promptise
  • Use cases
  • Roadmap
  • Guides
  • Learning Paths
  • Questions

[04] Company

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

© 2026 Promptise by Manser Ventures. All rights reserved.

hello@promptise.com
← 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.

7
guides
2
Beginner
4
Intermediate
1
Advanced
2 h
of reading

Featured · start here

ReAct Agent From Scratch in Python: The Reason-Act Loop

Build 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 minRead the guide →

6 guides

  1. 01ReAct Agent Pattern: Tool Execution Loop Explained SimplyThe ReAct agent pattern explained simply: what an agent does after it calls a tool, a loop written by hand, the same agent in Promptise, where it breaks.Beginner · 14 minBuilding AI agents in PythonBeginner · 14 minBuilding AI agents in Python→
  2. 02What 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 minBuilding AI agents in PythonBeginner · 7 minBuilding AI agents in Python→
  3. 03Reasoning Effort for AI Agents: When High HurtsReasoning effort for AI agents: how low, medium, high and xhigh work at OpenAI, Anthropic and Google, when high effort hurts, and how to measure it.Intermediate · 15 minModels and providersIntermediate · 15 minModels and providers→
  4. 04AI 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 minObservability and debuggingIntermediate · 18 minObservability and debugging→
  5. 05AI 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 minCost control and rate limitsIntermediate · 18 minCost control and rate limits→
  6. 06Context Compaction for AI Agents: Trim vs SummarizeContext compaction for AI agents: drop, trim or summarize, what each keeps on a real transcript, why agents forget file paths, and how to compact safely.Advanced · 20 minMemory, context and RAGAdvanced · 20 minMemory, context and RAG→

Related topics

  • Cost Control29
  • Tool Calling34
  • ReAct5
  • Agent Runtime40
  • Context Engineering12
  • Evals and Testing25
  • Model Selection and Routing21
  • Observability24

Topic hubs

  • Building AI agents in Python→
  • Agent reasoning patterns→
  • Cost control and rate limits→
  • Models and providers→

By category and level

  • AI Engineering guides147
  • Prompt Engineering guides54
  • Beginner guides75
  • Intermediate guides140
  • Advanced guides38

Search every guide.

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

All guidesLearning paths