Domain 4: Cost management
This article describes how to keep agent spending attributable and bounded as usage grows, covering the separate layers an agentic workload bills across, the tagging and reporting setup that attributes each layer back to the team that owns it, the alarms that catch a runaway agent loop within minutes, and the optimization levers worth pulling. It also sets out where a managed agent shifts that work away from your teams.
Generative AI (gen AI) costs work differently than traditional compute, which often surprises teams. You pay per token processed for both input and output. A longer prompt costs more than a shorter one, and a more capable model costs more than a simpler one. Without visibility and controls, costs can scale faster than the value delivered.
Cost optimization in gen AI means maximizing value per token. Your strategy must identify which workloads justify premium models, where caching makes sense, and how to structure prompts for efficiency without sacrificing quality. The goal is predictable costs that scale with business value, not with token consumption.
Implementing cost visibility for agentic workloads
Agentic workloads accrue costs across multiple layers that vary by agent implementation.
First, runtime charges are based on active CPU and memory consumption, not tokens. You can track usage metrics (CPUUsed-vCPUHours, MemoryUsed-GBHours) by agent and endpoint in the GenAI Observability dashboard in Amazon CloudWatch. For granular visibility, session-level usage logs report at 1-second resolution.
Second, when AgentCore hosted agents call foundation models, those invocations bill separately as standard Amazon Bedrock inference on a per-token basis. You can track token usage under Model Invocations in the CloudWatch GenAI Observability dashboard. This section shows invocation counts, latency, and token counts by model. To see invocation-level metrics, you must turn on Model Invocation Logging in the Amazon Bedrock console.
Additional AgentCore services, such as Gateway, Memory, Identity, Observability, Evaluations, Browser, and Code Interpreter, each have their own consumption-based pricing that appears as separate line items.
When an agent investigates an incident, a user or alarm first triggers the agent through its AgentCore Runtime endpoint. The runtime starts a session, and CPU and memory costs start accruing during active processing. These are visible in the Amazon Bedrock AgentCore namespace. Then, the agent calls a foundation model to evaluate the problem, which invokes token costs. Every token in the prompt (system instructions, the user's question, any tool results injected as context) counts as an input token. Every response that the model generates counts as an output token. You can track the per-invocation token count broken down by model ID under Model Invocations in the CloudWatch GenAI Observability dashboard. Next, the agent might invoke an Model Context Protocol (MCP) tool through Gateway to query CloudWatch Logs, which incurs a Gateway invocation. The tool results come back, the agent calls the model again with the new context, and then another round of token costs accrue. This loop of reasoning, tool invocation, and reasoning again can repeat multiple times in a single session, and each model call adds to the token bill. When the agent completes the analysis, you’ve already accumulated runtime costs for the session duration, token costs across several model invocations, and Gateway invocation costs for each tool call.
Key metrics:
-
CPUUsed-vCPUHours and MemoryUsed-GBHours in the Amazon Bedrock-AgentCore namespace for runtime costs
-
Token counts in the GenAI Observability dashboard for inference costs
-
Gateway invocation metrics in the Amazon Bedrock-AgentCore namespace for tool call costs
Cost allocation
Cost allocation starts with tagging. For our triage agent example, attribute the runtime costs, model inference costs, and Gateway costs back to the team or application that owns the agent. For model inference, create an application inference profile in Amazon Bedrock for your triage agent and attach cost allocation tags such as CostCenter, Team, and Application. When your agent code invokes the model through the inference profile Amazon Resource Name (ARN) instead of the model ID directly, every token that the agent’s model calls and consumes receives a tag and appears in your cost allocation reports. For Runtime and Gateway costs, tag your agent runtime, endpoints, and gateway resources directly.
AgentCore supports resource-level tagging for cost allocation, access control, and resource organization. After the tags are in place, activate them as cost allocation tags in the AWS Billing dashboard. You can then filter AWS Cost Explorer by your triage agent's tags to get the full picture: How much the runtime session cost, how much the model invocations cost, and how much the Gateway tool calls cost, all attributed to the right team. Each team/model combination will need a separate inference profile for you to truly attribute costs, and this can scale quickly.
If you’re using the bedrock-mantle endpoint, then you can use Amazon Bedrock Projects. Projects provide application-level isolation for your gen AI workloads, access control, and cost monitoring. Unlike inference profiles, projects don’t depend on a single model.
If you use AWS Identity and Access Management (IAM) principals to access Amazon Bedrock, then you also attribute cost per principal automatically. This applies to an IAM user, application's assumed role, or federated identity from a provider such as Okta or Entra ID. After you turn on IAM principal data in your Cost and Usage Report (CUR) 2.0 export, the line_item_iam_principal column shows who called Amazon Bedrock and what each agent spent. This way, you don’t need to manage any resources. To consolidate this by team or cost center, attach principal or session tags to your IAM identities and activate them as cost allocation tags. They then appear in Cost Explorer under the iamPrincipal/ prefix.
Before you run inference, use the Amazon Bedrock CountTokens API to estimate costs. This helps you understand the impact of prompt changes before they reach production. The API returns the exact token count charge if the model received the same input, with no cost for the count itself. Use this API during prompt development to optimize for both quality and efficiency.
With visibility and attribution in place, set up anomaly detection to catch unexpected cost spikes. AWS Cost Anomaly Detection uses machine learning to identify unusual spending patterns across your AWS services. This service can then alert you through Amazon Simple Notification Service (Amazon SNS) or email when it detects deviations from your baseline.
For more granular, real-time monitoring, create CloudWatch alarms on the metrics that you're already collecting. Set thresholds on token counts, AgentCore runtime hours (CPUUsed-vCPUHours and MemoryUsed-GBHours), or Gateway invocations that trigger when usage exceeds expected bounds. CloudWatch anomaly detection determines normal patterns for these metrics and alerts on deviations, without the need for static thresholds. This matters most for agentic workloads, where a runaway agent loop can rack up significant costs in minutes.
Optimization strategies
Prompt caching reduces costs when you have repeated context. Some agents call models directly, such as those hosted in AgentCore Runtime through the Converse or InvokeModel APIs. For these agents, turn on prompt caching when you reference the same documents, system prompts, or tool definitions across requests.
You pay for cached tokens at a reduced rate compared to standard input tokens. The cache has a 5-minute time to live (TTL) that resets on each hit. Select models also support an extended 1-hour TTL for longer-running sessions where follow-up requests might occur more than 5 minutes apart. For example, if users upload documents and ask multiple questions about them, then cache the document content so subsequent queries don't reprocess it. Caching works best when your static content meets the minimum token threshold for the model that you're using. Each model has its own minimum tokens per cache checkpoint, maximum number of checkpoints per request, and supported TTL options. For current supported models and limits, see Prompt caching for faster model inference.
Route requests to appropriately sized models. Not every task needs a frontier model. Classification, extraction, and formatting often work well on smaller models, such as Amazon Nova Micro or Claude Haiku, at a fraction of the per-token cost. Reserve larger models for complex reasoning, multi-step workflows, or deep domain knowledge. Some teams use tiered routing so that you can start small and escalate only when confidence drops or there’s a task demand.
Trim prompts deliberately. Every token in your prompt costs money. Review your prompts for unnecessary verbosity, redundant instructions, or excessive examples. Structured templates help maintain consistency while controlling token count. Set maximum prompt lengths, and monitor actual prompt sizes over time to detect drift.
Treat prompts as artifacts that are worth optimizing. Add governance, such as approval workflows for new model subscriptions, sandboxes with spending caps, and cost visibility for consuming teams.
AWS DevOps Agent: A different cost model
AWS DevOps Agent has a different cost structure from custom-built agents. With AgentCore-hosted agents, you manage costs at the token and compute level, optimizing prompts, selecting models, configuring caching, and tagging for attribution. With AWS DevOps Agent, the inference costs, model selection, and orchestration complexity are hidden. You don't pay per token or manage model subscriptions. Instead, you pay per agent-second of active work at a single rate across all task types, such as investigations, evaluations, and on-demand Site Reliability Engineer (SRE) tasks. The service charges only for agent-seconds of active work, with no charges during idle or waiting periods. AWS Support customers receive monthly credits toward AWS DevOps Agent usage based on a percentage of their support spend. This can help offset costs for teams who are already on AWS Business+, AWS Enterprise, or AWS Unified Operations support plans.
AWS DevOps Agent publishes CloudWatch metrics under the AWS/AIDevOps namespace, including ConsumedChatRequests, ConsumedInvestigationTime, and ConsumedEvaluationTime, broken down by Agent Space. Use these metrics to monitor usage patterns and set alarms when consumption exceeds expected thresholds.
This cost structure can help simplify cost management. Teams don't worry about prompt efficiency, model tiering, or token consumption, and a poorly constructed prompt can't inflate the bill. There's no need to build cost attribution tagging for individual model invocations. Investigation cost is a function of elapsed agent time, not token consumption, which makes it easier to forecast.
AWS DevOps Agent generates costs in the services that it connects to. When the agent queries CloudWatch metrics, retrieves logs, or calls third-party observability APIs, those services charge as normal. The same applies to custom agents on AgentCore Runtime. Every MCP tool invocation that queries CloudWatch Logs, calls a third-party API, or retrieves data from a database incurs costs in those downstream services.
Factor these downstream costs into planning for both approaches, especially for high-frequency investigations that issue many queries. Monitor CloudWatch and third-party API costs alongside your Agent Spaces and AgentCore agents to see the full picture.
← Back to main article | Previous: Data access and integration | Next: Security and forensics →
About the Author
Brian Simpson-Adkins is a Principal Technical Account Manager (TAM) in AWS Global Financial Services. He has over 20 years of experience in architecture, operations, and automation. Based in Australia, he partners with customers worldwide, and helps them resolve operational challenges through data-driven insights.
- Language
- English

Relevant content
AWS OFFICIALUpdated a month ago
AWS OFFICIALUpdated a month ago- Accepted Answer
asked 4 years ago
AWS OFFICIALUpdated 8 months ago
AWS OFFICIALUpdated 3 years ago