Monitoring and Controlling Agent Resource Consumption
This lesson explains how to monitor agent resource consumption, which varies widely because agents decide how many model and tool calls a task needs.
Learning outcomes
After completing this lesson, you will be able to:
- Identify what agents consume.
- Monitor per-session consumption.
- Control consumption with iteration limits and token budgets.
What agents consume
Each agent task consumes model tokens for every reasoning step (with the growing context re-sent each time), tool calls that may invoke Lambda functions, APIs or databases, runtime compute (AgentCore Runtime bills active CPU and memory per session, so time spent waiting for model responses uses little CPU), memory operations and storage, and gateway calls. Multi-agent systems multiply these.
What an agent session costs
Monitoring consumption
AgentCore Observability and CloudWatch generative AI observability report per-session tokens, model and tool call counts, latency and errors. Useful derived metrics are tokens per task, iterations per session, tool calls per task, session duration and cost per completed task. Distribution views matter more than averages: a few runaway sessions can dominate cost.
Controlling consumption
Set maximum iterations, session time limits and token budgets per task; trim or summarise context between steps; give tools precise descriptions so the agent picks the right one first; use smaller models for simple sub-tasks; cache tool results; and alarm on outliers. The following table summarises the patterns.
| Pattern | Signal | Control |
|---|---|---|
| Runaway loops | Iterations per session spikes | Maximum iterations, loop detection |
| Context growth | Tokens per step rising within sessions | Summarize or trim context |
| Tool thrashing | Many tool calls per task | Better tool descriptions, caching |
| Expensive model for simple steps | High cost per task | Route sub-tasks to smaller models |
| Long idle sessions | Long session duration | Session time limits |
The following diagram shows the distribution of tokens per session for an agent, including a long tail caused by repeated tool calls.

Control agent spend
A few expensive sessions
An agent's monthly cost doubles while task volume is flat. The median session uses 12,000 tokens, but the 99th percentile uses 400,000.
Traces of the expensive sessions show the agent repeatedly calling a search tool with slightly reworded queries when no result is found. A maximum of three searches per task, an instruction to ask the user for clarification after an empty result and an alarm on sessions above 100,000 tokens bring cost back down. Looking only at average tokens per session would have hidden the outliers that caused the increase.
Why look at percentiles rather than averages for agent cost?
Show answer
A few runaway sessions can dominate cost while the average looks normal.
Exam Tips
Remember for the exam
- Monitor tokens, iterations and tool calls per task, not just per request.
- Look at percentiles; a few runaway sessions can dominate cost.
- Cap iterations, session duration and token budgets.
- AgentCore Runtime bills active CPU and memory consumption.
- Route simple sub-tasks to smaller models.