TECHNOLOGY

Pydantic AI request limits count committed model turns

In this article
THE QUICK TAKE

Use request_limit to bound the agent loop, and inspect retry layers separately when explaining external request count, elapsed time or cost.

Compare the agent counter with service traffic

An operator sees a small request count in a research run but more HTTP attempts in service logs. That can be consistent with Pydantic AI’s documented accounting. The agent guide defines RunUsage.requests around responses committed to the run’s history, representing turns of the agent loop. It should not be presented as the number of packets or requests sent across a provider boundary.

Interpret request_limit as a loop boundary

The usage API says request_limit bounds loop turns rather than provider requests. Attempts abandoned by a fallback, continuation requests and SDK or transport retries are not individually counted as additional turns. The application can therefore stay within its loop cap while making more network attempts. A run reaching its request limit also raises instead of automatically delivering an accepted final answer.

Locate retries beneath the recorded response

The retry guide separates transport retries and provider SDK retries from model-level fallback and correction. Lower layers can repeat a request before the agent receives its final response or exception, without adding a conversation message for each attempt. Review which layers are enabled and who owns the retry policy. Several independently configured layers can multiply work while the visible conversation remains short.

Keep token and cost accounting separate

The usage reference explains that token and cost limits can account for rejected responses and continuation work even when those attempts do not add loop turns. A low request count is therefore insufficient evidence of low token consumption or low billed work. Preserve reported usage and measurement gaps instead of estimating every resource from one counter. Task budgets can distinguish loop allowance, overall time and the specific service resources the application must control.

Explain a run using the relevant layer

For an incident, connect the agent turn to its model response and the lower-level attempts that preceded it. Tool observations should identify retries and fallback outcomes where they explain delay. The answer can then state why a bounded reasoning loop produced several service attempts without declaring the limit broken. If the requirement is a strict external request ceiling, implement and assess a boundary that actually measures that traffic rather than substituting the loop-turn counter.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles