---
title: Which CrewAI settings cap agent iterations, rate and execution time?
url: https://opencontroller.lyzr.com/blog/crewai-max-iterations-and-rate-limits
published: 2026-11-17
updated: 2026-11-17
author: Lyzr
---

# Which CrewAI settings cap agent iterations, rate and execution time?

**CrewAI gives each agent four runaway controls: `max_iter` (default 20) caps reasoning iterations, `max_rpm` caps requests per minute, `max_execution_time` caps task time in seconds, and `max_retry_limit` (default 2) caps retries on errors. Only `max_iter` and `max_retry_limit` have limits by default; rate and time are unlimited unless you set them.**

CrewAI agents loop through think, act and observe until they produce a final answer. Those loops are where cost and API pressure come from. The settings below are the first line of defence, set in code or in agent definition files.

## What does each setting do?

| Attribute | Type | Default | What it caps |
|---|---|---|---|
| `max_iter` | int | 20 | Iterations before the agent must give its best answer |
| `max_rpm` | Optional[int] | None (no limit) | Requests per minute from this agent |
| `max_execution_time` | Optional[int] | None (no limit) | Seconds allowed for task execution |
| `max_retry_limit` | int | 2 | Retries when an error occurs |
| `respect_context_window` | bool | True | Summarises history to stay within the context window |

Defaults are from the current CrewAI agents documentation. Check them against the version you run.

The `Crew` class also accepts `max_rpm`, which applies a requests-per-minute ceiling across the crew's agents. Use it when several agents share one provider quota.

## Why are the defaults not enough for production?

- **`max_iter=20` is a ceiling on reasoning loops, not on cost.** Twenty iterations with large tool outputs can still use a lot of tokens.
- **No `max_rpm` means no rate limit.** A crew fanned out across many tasks can hit provider limits and trigger retries, which then multiply calls.
- **No `max_execution_time` means a slow tool can hold a task open** indefinitely from the agent's point of view.
- **Retries stack.** Two retries per error across many agents and tasks multiply load during a provider incident.

Also note that `allow_code_execution` and `code_execution_mode` are deprecated in current CrewAI docs and the `CodeInterpreterTool` has been removed. If older crews still set them, review how code execution happens now.

## How do you choose values?

1. **Measure normal runs first.** Trace a week of successful tasks and record iterations, requests and duration per agent.
2. **Set `max_iter` just above the high end** of successful runs. Hitting it should be an anomaly.
3. **Set `max_rpm` per agent** from your provider quota divided across agents that run concurrently, and set crew-level `max_rpm` as the overall ceiling.
4. **Set `max_execution_time`** from the slowest legitimate task plus headroom. Customer-facing crews need tighter limits than overnight ones.
5. **Keep `max_retry_limit` low** (the default of 2 is reasonable) and make sure retries back off.
6. **Alert when a cap is hit.** Log the agent, task, crew version and which limit tripped.

For task-level output checks, see [CrewAI task guardrails](/blog/crewai-task-guardrails).

## What do these settings not cover?

They are per-process limits inside your code. They do not:

- Enforce token or spend budgets per agent across processes and deployments.
- Stop a single tool call with a harmful side effect.
- Give security a view of all crews running across teams and clouds.
- Survive a developer editing the value in a pull request.

So pair them with controls outside the framework: per-agent budgets and [rate limits at a gateway](/blog/how-to-rate-limit-ai-agents), tool allowlists, and incident playbooks. The [rogue-agent runtime pillar](/blog/how-to-stop-a-rogue-ai-agent) covers escalation from alert to quarantine, and [governing CrewAI agents in production](/blog/govern-crewai-agents-in-production) covers the rest of the CrewAI control set. For the cross-platform view, see the [platform guides pillar](/blog/how-to-govern-ai-agents-across-platforms).

## How Opencontroller does this

Opencontroller adds limits that do not depend on each crew's code. Point CrewAI's model calls at its LLM Gateway through an OpenAI-compatible endpoint to get routing, fallback and retry, caching and cost attribution per agent and per version. Rogue-agent handling watches for behavioural deviation, alerts, and can automatically quarantine or kill an agent under estate-wide policies. Registration in the registry does not mean runtime takeover: enforcement depth depends on the traffic path. [Book a demo](https://www.lyzr.ai/book-demo/).

## Frequently asked questions

**What is the default max_iter for a CrewAI agent?**
20, per the current CrewAI agents documentation. After that the agent must return its best answer.

**Does CrewAI rate-limit agents by default?**
No. `max_rpm` defaults to None, which means no limit. Set it per agent, and at crew level when agents share a quota.

**Is max_execution_time in seconds or minutes?**
Seconds. It defaults to None, so there is no time limit unless you set one.

## Key facts

- CrewAI Agent attributes (current docs): max_iter default 20; max_rpm Optional[int], default None (no limit); max_execution_time Optional[int] seconds, default None; max_retry_limit default 2; respect_context_window default True.
- CrewAI Crew also accepts max_rpm as a crew-wide requests-per-minute ceiling.
- allow_code_execution and code_execution_mode are deprecated and CodeInterpreterTool has been removed in current CrewAI docs.
- Framework caps do not enforce cross-process token budgets or stop single harmful tool calls; pair with gateway budgets and tool allowlists.
- Opencontroller by Lyzr: LLM Gateway with per-agent, per-version cost attribution and rogue-agent quarantine/kill; pricing starts from $250K per deployment per year.

## Related

- [How do you govern CrewAI agents in production?](https://opencontroller.lyzr.com/blog/govern-crewai-agents-in-production.md)
- [How do CrewAI task guardrails work and where do they fall short?](https://opencontroller.lyzr.com/blog/crewai-task-guardrails.md)
- [How do you rate-limit AI agents?](https://opencontroller.lyzr.com/blog/how-to-rate-limit-ai-agents.md)
- [More on Platform Guides](https://opencontroller.lyzr.com/blog/cluster/platform-guides)
