Runtime limits

The runtime limits cap a run: how long an agent may run, how many times a loop may iterate, how many rows a database call may return, how long an agent definition may be, and how much an agent may spend on LLM calls. The run time and the LLM cost limits belong to each agent. The other limits are account-wide: developers edit them in the UI under Guardrails, and they apply to every agent in the account.

How the limits are checked

The limits are checked while the agent runs. Elapsed time is checked between commands, and inside loops at the interval that the yield loops after setting gives. A run past the time limit ends with the result code timedOut, and the message names the limit. A long LLM or API call in progress ends only when the call's own timeout fires. A loop that exceeds the iteration limit fails the run. A db command returns at most the row limit. The definition length applies to the JSONC text of a draft, comments included. The stream heartbeat sets how often a streamed response sends a keep-alive line.

The two limits each agent carries

The time limit and the LLM cost limit belong to the agent, not to the account. A new draft starts with default limits, and a draft made from a published agent starts with that agent's limits. The limits are saved with the draft, the validation run is held to them, and publishing carries them to the agent. A developer can also change the limits of a published agent directly. That change applies from the next run, does not make a new version, and is recorded in the audit log.

Each limit covers one run: from the request to the answer, or to the point where the agent pauses on an ask. The run that continues after the answer starts with the full limits again. The performance report and the cost report show the duration and the LLM cost of each agent's runs, which is the evidence for choosing both.

LLM cost limit

Each agent carries its own LLM cost limit: the most one run may spend on LLM calls, in US dollars. After every LLM call the agent server prices the call from its token counts and the per-million-token prices in the LLM profile, and adds the amount to the run's total. Once the total passes the limit, the run stops with the result code errorInAgent, and the person is told that the request reached the agent's cost limit. The stop cannot be caught by onError, and it applies inside tool calls and parallel branches. Retries count toward the total. A profile with no prices adds nothing to the total, so a run on such a profile never trips the limit.

FieldTypeDefaultDescription
maxIterationLoopsinteger10000The most iterations a 'while' or 'for' may run. A loop inside a loop is counted separately.
yieldLoopsAfterinteger1000How many iterations a loop runs before yielding, so the runtime limit can be checked.
dbMaxRowsinteger10000The most rows a single db command may return.
agentMaxLengthinteger20480The most characters an agent definition may contain.
streamHeartbeatinteger15How often a noop is sent on an idle output stream, in seconds, so browsers and proxies do not close it while the agent works.