
AWS AgentCore Cost Optimization: Keep Your Agent Bills Under Control
This article explores how six cost-optimization layers — model tiering, prompt caching, step budgets, memory selectivity, observability sampling, and network optimization — turn an unpredictable agent bill into a governed, affordable system that scales to 100 agents without surprise invoices.
Most teams that ship an AI agent start with the simplest possible setup: one model, one prompt, one hope that the bill will stay reasonable. It's roughly the same pattern behind every internal assistant, every customer-facing chatbot, every autonomous workflow shipped in the last two years.
It also explains why those teams all have the same conversation at the end of the first month. The bill arrives, and it's three to ten times higher than anyone estimated. The agent worked — it just cost dramatically more than anyone expected, and nobody can explain exactly where the money went.
Classic serverless pricing is predictable. You know your Lambda invocations, your API Gateway calls, your DynamoDB reads. You can budget to within 10% before going live. Agentic systems break that predictability. Agent costs are emergent — they depend on how many reasoning steps the agent decides to take, how long the context window grows across a session, which tools it invokes and how many times, and how often it backtracks when a tool call fails. A task you estimated at 3 LLM calls might take 11 in production when a tool returns an unexpected response and the agent retries.
Organizations that want AI agents to stay affordable at scale face a specific set of challenges:
- They need to know what they're paying for — not just "tokens" but which of the eight separate billing dimensions is actually driving the cost.
- They need agents to use the right model for the task, not the most expensive one for every task.
- They need prompts that hit the cache on repeated calls, not prompts that miss because volatile content sits at the top.
- They need bounded tool use, so a failed API call doesn't trigger an unbounded retry loop that multiplies Gateway operations.
- They need memory writes that are selective, not memory writes that accumulate an ever-growing storage bill.
- They need observability that samples in production, not observability that traces every single interaction at full fidelity.
What makes agentic costs different
A standard API call has predictable cost. You know the input size, the output size, the compute time. The bill is the sum of those components.
An agentic system adds a feedback loop. The model decides what to do next, and that decision changes the cost of everything that follows. A "simple" task that the model handles in one turn costs X. The same task, when the model decides to verify its work by calling two additional tools and then re-checking the result, costs 4X. You didn't change anything — the model decided to be more thorough, and you paid for it.
The worst part: you are not paying a single meter. With Amazon Bedrock AgentCore you are paying across five to eight separate billing dimensions simultaneously — Runtime vCPU-seconds, Gateway operations, Policy authorization requests, Memory events, Observability CloudWatch ingestion, and LLM inference tokens on top of all of that. Most teams track only one of these (tokens), which explains why the bill surprises them.
The popular shorthand for this is "token cost," and most cost discussions stop there. But token cost is one line item in a larger system. A 3,000-token user query that triggers 6 tool calls, writes 4 memory events, and runs for 18 seconds of CPU time will cost dramatically more than the token price alone suggests. The rest of this article is about what sits around token optimization to make the whole system affordable.
An LLM call alone is not a cost problem. It's one component of one operation inside a larger loop.

Key features of a cost-optimized agent system
Eight billing dimensions, eight opportunities
"Optimize costs" sounds like one task. In practice it's several distinct optimizations with different levers, and conflating them produces predictable failures — a team that caches prompts perfectly but runs all agents on the flagship model, or a team that tiers models correctly but pays for 100% trace logging in production.

Runtime billing (vCPU-seconds + GB-seconds) — the compute time your agent actually uses. AgentCore charges only for active CPU; I/O wait is free. This is genuinely different from traditional always-on compute, and it means agents that spend most of their time waiting for LLM responses cost less than you'd expect from a simple compute comparison.
Gateway billing (per MCP operation) — every ListTools, CallTool, and Ping call costs money. If your agent calls ListTools on every session start to discover available tools, you're paying for a discovery operation on every single interaction. Cache the tool schema at agent initialization and refresh it only when your MCP server deployment changes.
Policy billing (per authorization request) — each tool call triggers a policy check. This is usually cheap, but in a 100-agent deployment with unbounded tool calls, it compounds. A step budget that limits tool calls also limits policy checks.
Memory billing (per event + per stored record/day + per retrieval) — short-term memory charges per raw event created; long-term memory charges per stored record per day plus per retrieval call. Both can grow surprisingly fast. Writing four separate events per turn (user message, tool call, tool result, assistant response) costs 4x what a single batched event costs.
Observability billing (CloudWatch ingestion + storage + queries) — full OpenTelemetry traces for every agent interaction at scale is the single easiest way to generate a large CloudWatch bill. Development habits transfer to production without anyone noticing until month-end.
LLM inference billing (input + output tokens) — the line item everyone tracks. Still the largest single cost driver in most deployments. Prompt caching can reduce input costs by 90% on repeated calls; model tiering can reduce total inference costs by 87%.
Identity billing (per OAuth token / API key request) — usually free when called through Runtime or Gateway. Only matters if you're making direct calls outside the agent loop.
Network billing (standard EC2 egress rates) — cross-AZ data transfer, NAT Gateway data processing, egress to the internet. PrivateLink for AWS service calls can eliminate the NAT Gateway component entirely.
Model tiering — the highest-leverage optimization
Model selection isn't one decision you make once. In practice it's a per-agent decision based on task complexity, and getting it wrong is the most expensive single mistake in a multi-agent deployment.
The instinct is to use the "best" model everywhere. Claude Sonnet for everything. Opus for the hard cases. The reasoning is understandable: you want quality, and the difference between a good answer and a mediocre one matters to the business.
The problem is that "best" conflates two different things: capability ceiling and task fit. A model that can handle complex multi-step planning is also capable of doing JSON extraction — but it's dramatically overqualified for it. Running a Tier 3 utility agent on Sonnet is the equivalent of hiring a senior architect to do data entry. It works, but it costs 10x more than it has to.
The foundation is to divide agents into three tiers based on decision complexity — not on "business importance". A critical invoice validation agent that always follows 3 fixed steps is a Tier 3 agent. It's key for the business, but trivial for the model.
Tier | Model | Input / 1M tokens | Output / 1M tokens | Use Case |
|---|---|---|---|---|
Tier 1 — Orchestrator | Claude Sonnet 4.6 | $3.00 | $15.00 | Multi-step planning, cross-agent coordination, ambiguous queries |
Tier 2 — Specialist | Claude Haiku 4.5 | $0.25 | $1.25 | Domain-specific tasks, structured output, API interactions |
Tier 3 — Utility | Nova Micro | $0.04 | $0.14 | Routing, classification, JSON formatting, yes/no checks |
The math is stark. 100 agents, 1,000 sessions/month each, 10 LLM calls per session, average 2,000 input + 300 output tokens per call. All on Sonnet: $10,500/month. Tiered (10 Sonnet / 40 Haiku / 50 Nova Micro): $1,382/month. Same workload, same business outcomes, 87% cost reduction.

Prompt caching — structure determines savings
Prompt caching isn't a feature you "turn on." It's a structural property of how you build your prompts, and getting the structure wrong means the cache misses on every call regardless of what flags you set.
The mechanism is simple: Bedrock stores a prefix of your prompt and serves it from cache on repeated calls. Cache read tokens are dramatically cheaper than full input token pricing. For agents with a stable, long system prompt (tool schemas, business rules, persona), caching can reduce input token costs by over 90% on repeated calls.
The catch is that the cache only hits if the prefix is identical across calls. A prompt where the user message sits at the top will miss on every turn, because the prefix changes. A prompt where system instructions, policies, and preferences sit at the top — and the volatile content (user message, recent context, retrieved facts) sits at the bottom — will hit on every turn after the first.

# Python — enabling prompt caching on a Strands agent system promptimport boto3import json
bedrock = boto3.client("bedrock-runtime", region_name="eu-west-1")
system_prompt = """You are a FinOps specialist agent responsible for analyzing AWS cost anomalies.You have access to the following tools: [... long tool schema ...]Always respond with structured JSON."""
response = bedrock.invoke_model( modelId="anthropic.claude-sonnet-4-5", body=json.dumps({ "anthropic_version": "bedrock-2023-05-31", "max_tokens": 1024, "system": [ { "type": "text", "text": system_prompt, "cache_control": {"type": "ephemeral"} # cache this prefix } ], "messages": [{"role": "user", "content": user_message}] }))Step budgets — bounded tool use
Tool calls aren't free. Every call through AgentCore Gateway costs money on two dimensions: the Gateway operation itself, and the tokens added to the next LLM context (the tool result goes back into the prompt). Unbounded tool use can triple your per-request cost when an agent decides to verify the same data source three times or retries a failed API call in an uncontrolled loop.
The solution is a step budget: a maximum number of tool calls per agent turn, enforced in code. When the budget is exhausted, the agent must return its best answer with current information rather than making additional calls. This isn't about limiting capability — it's about matching the budget to the task complexity.
Tier 1 orchestrators get 15 steps. They need room to explore, coordinate across sub-agents, and handle genuinely complex multi-step planning. Tier 2 specialists get 6 steps. They're working on a focused task with a known shape. Tier 3 utilities get 3 steps. They're doing classification, routing, or formatting — tasks that should never need more than a few operations.
# Python — step budget enforcer for a Strands agentfrom strands import Agentfrom strands.hooks import AfterToolUse
class StepBudgetGuard: def __init__(self, max_steps: int): self.max_steps = max_steps self.step_count = 0
def on_tool_use(self, event: AfterToolUse): self.step_count += 1 if self.step_count >= self.max_steps: event.agent.set_stop_reason( f"Step budget of {self.max_steps} tool calls reached. " "Returning best answer with available information." )
STEP_BUDGETS = { "tier_1": 15, # orchestrators "tier_2": 6, # specialists "tier_3": 3, # utilities}Step budgets also prevent the worst-case scenario: tool-call storms. An agent without a budget can retry a failed tool call repeatedly, especially if the tool returns ambiguous errors. 10 retries on a 6-tool-call task becomes 60 Gateway operations and 60 policy checks. The budget caps the damage.
Memory selectivity — not every session needs long-term storage
AgentCore Memory has two separate billing meters: short-term memory charged per raw event created, and long-term memory charged per stored record per day plus per retrieval call. Both can grow surprisingly fast in high-volume deployments.
The mistake is treating memory as a binary: either you have it or you don't. In practice, memory needs are tiered just like model selection. Tier 1 orchestrators that coordinate across sessions, learn from past decisions, and maintain continuity for users — they need long-term memory. Tier 3 utilities executing deterministic tasks on fresh inputs — they almost never need it. They have no cross-session learning to do.
Short-term memory has its own optimization: batching. If your agent writes user message, tool call, tool result, and assistant response as four separate events, you pay 4x the rate you would pay for a single batched event. Combine related events within a single turn into one write.
# Python — conditional LTM write based on agent tier and importancedef maybe_persist_memory( session_id: str, agent_config: dict, summary: str, importance_score: float): """Only write LTM for Tier 1 agents with high-importance sessions.""" tier = agent_config["tier"] ltm_threshold = {1: 0.4, 2: 0.75, 3: 999.0} # Tier 3 never writes LTM
if importance_score < ltm_threshold[tier]: return # Skip LTM write
agentcore_memory.create_memory_record( memoryId=agent_config["memory_id"], content=summary, sessionId=session_id, )Observability sampling — production is not development
Full OpenTelemetry traces for every agent interaction at scale is the single easiest way to generate a large CloudWatch bill. The pattern is familiar: development habits transfer to production without anyone noticing. In development, you want full traces on everything — you're debugging, you need visibility. In production, you don't need 100% visibility. You need enough visibility to catch anomalies and debug issues when they arise.
A 10% sampling rate captures sufficient data for performance analysis and anomaly detection while cutting your CloudWatch ingestion cost by 90%. For debugging, temporarily flip the sample rate to 100% via AppConfig — no redeployment needed. The key is making the sampling rate a runtime configuration, not a compile-time constant.
# Python — dynamic trace sampling with AWS AppConfigdef get_trace_sample_rate(agent_tier: int) -> float: """Read sampling rate from AppConfig — no redeploy needed to adjust.""" config = appconfig.get_latest_configuration(...) return config["sampling_rates"][f"tier_{agent_tier}"]
# AppConfig document:# {# "sampling_rates": {# "tier_1": 0.25, # orchestrators: 25%# "tier_2": 0.10, # specialists: 10%# "tier_3": 0.03 # utilities: 3%# }# }Log retention is the other half. CloudWatch log groups created by AgentCore have no default retention — logs accumulate indefinitely. Set a retention policy on every log group. 30 days is sufficient for most production workloads. 90 days if compliance requires it. But not indefinite.
Network optimization — the invisible cost driver
Network costs are easy to overlook because they don't show up in the agent-specific billing dimensions. They show up in your general AWS bill, mixed in with everything else. But for high-volume agent traffic, they compound quickly.
Three optimizations matter: same-AZ placement, PrivateLink instead of NAT Gateway, and prompt session termination.
Same-AZ placement keeps your AgentCore Runtime, Gateway, Knowledge Bases, and application endpoints in the same Availability Zone. Cross-AZ data transfer within a region is billed at EC2 rates — small per-GB, but it adds up.
PrivateLink for AWS service calls (DynamoDB, S3, Secrets Manager, Bedrock) eliminates NAT Gateway data processing charges. NAT Gateway charges per-hour plus per-GB of data processed. PrivateLink charges per-hour only, at a lower rate. For agents making frequent AWS API calls, this is a meaningful monthly saving.
Session termination matters because AgentCore Runtime microVMs run until the session is explicitly terminated or times out. Even with the active-CPU-only billing model, background processes and memory allocation continue until shutdown. Implement explicit session termination as soon as the agent task completes — don't rely on timeout defaults.
# Terraform — VPC endpoint for Bedrock (avoids NAT Gateway cost)resource "aws_vpc_endpoint" "bedrock_runtime" { vpc_id = aws_vpc.main.id service_name = "com.amazonaws.eu-west-1.bedrock-runtime" vpc_endpoint_type = "Interface"
subnet_ids = aws_subnet.private[*].id security_group_ids = [aws_security_group.vpc_endpoints.id]
private_dns_enabled = true
tags = { Name = "bedrock-runtime-endpoint" Project = "agentcore-finops" }}Common cost scenarios
Optimized vs unoptimized — the same workload
100 agents, 10,000 sessions/month, 6 tool calls per session. The only difference is whether the six optimization layers are applied.
Component | Optimized | Unoptimized |
|---|---|---|
LLM inference | ~$1,382 (tiered + caching) | ~$10,500 (all Sonnet, no caching) |
AgentCore Runtime | ~$280 | ~$620 (no session termination) |
Gateway ops | ~$45 (cached ListTools) | ~$180 (ListTools every call) |
Memory | ~$90 (batched STM, selective LTM) | ~$380 (individual events, LTM for all) |
Observability | ~$55 (10% sampling, 30-day retention) | ~$520 (100% traces, no retention) |
Network | ~$30 (PrivateLink, same-AZ) | ~$195 (NAT Gateway, cross-AZ) |
Total / month | ~$1,883 | ~$12,396 |
The delta is ~$10,500/month — roughly $126,000/year for the same business result. The dominant cost item is LLM inference, which is why model tiering is the single most important optimization. But the other five layers together account for another ~$1,500/month in savings.
An example journey: getting there from a flat deployment
You don't need to implement all six layers on day one. A working path looks like this:
Start with model tiering. This is the highest-leverage optimization. Audit your agents by task complexity, not by business importance. Move utilities to Nova Micro, specialists to Haiku, keep only orchestrators on Sonnet. This alone can cut your bill in half.
Add prompt caching. Restructure your prompts so stable content (system instructions, tool schemas, policies) sits at the top. Enable
cache_control on the stable prefix. Monitor cache hit rate in CloudWatch. Target >80% hit rate on repeated calls.Implement step budgets. Add a guard to your agent loop that counts tool calls and stops at the tier-appropriate limit. This prevents tool-call storms and bounds the worst-case cost of any single session.
Tier your memory writes. Move LTM writes behind an importance threshold. Tier 1 agents write with a 0.4 threshold. Tier 2 agents write with a 0.75 threshold. Tier 3 agents don't write LTM at all. Batch STM events within turns.
Sample observability. Flip your production tracing to 10% sampling via AppConfig. Set 30-day retention on all CloudWatch log groups. Keep 100% tracing available as a debug mode you can enable on demand.
Optimize network. Add VPC endpoints for Bedrock and AgentCore. Verify same-AZ placement. Implement explicit session termination in your agent cleanup.
Each step is independently useful, which is what makes this a migration rather than a rewrite.

Is cost optimization right for you?
A few signals are worth checking before you invest in all six layers.
Start with scale. If you're running 3 agents with 100 sessions/month, the absolute dollar difference between optimized and unoptimized is small — maybe a few hundred dollars. The ROI on implementation time might not be there. If you're running 50+ agents with thousands of sessions, the delta is in the thousands per month, and every layer pays for itself quickly.
Then there's variance. If your monthly agent bill is consistent and predictable, you might already be in a good place. If it swings wildly from month to month — or if you got a surprise invoice that was 3x what you expected — you have emergent cost dynamics that need governance.
Model mix is another tell. If you're already running different models for different tasks, you've got the hardest part done. If every agent runs the same flagship model, model tiering alone will likely cut your bill in half.
Observability habits matter too. If your team is already sampling traces in production and setting retention policies, you're ahead of most. If development configurations are shipping to production unchanged, you're paying for visibility you don't need.
And if there's any pressure from finance to explain or reduce AI costs, that alone settles it. The conversation goes better when you can show exactly which billing dimensions are driving the cost and exactly which levers you have to reduce it.
For most teams these signals don't show up one at a time — they compound. The good news is the AWS services involved (Bedrock, AgentCore, CloudWatch, VPC Endpoints) are usually ones you're already running. The lift is mostly architectural discipline, not new infrastructure.
Conclusion
Agent costs are emergent, and emergent costs require governance at multiple layers — not just token optimization. What separates an affordable multi-agent deployment from an unpredictable one is six coordinated optimizations: model tiering that matches capability to task complexity, prompt structure that hits the cache, step budgets that bound tool-call storms, memory selectivity that writes only what's worth keeping, observability sampling that captures enough without capturing everything, and network optimization that eliminates invisible data transfer costs.
None of it requires exotic infrastructure — it's a handful of AWS services arranged around a clear set of rules about what each agent tier is for. The tiered architecture in this article — 10 orchestrators on Sonnet, 40 specialists on Haiku, 50 utilities on Nova Micro — produces the same business outcomes as an all-Sonnet deployment at 15% of the cost. The delta is $126,000/year for a 100-agent fleet.
The pattern isn't "spend less on AI." It's "spend appropriately on AI" — flagship models for tasks that need them, utility models for tasks that don't, and governance at every layer where costs can compound unexpectedly.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article