Business Solutions

How I Built a FinOps Cost Optimization Agent on Amazon Bedrock AgentCore to Cut a Company’s AWS Bill

Ido Vapner
Jul 12, 2026
·
6 min read

The Business Challenge

A CIO at a large enterprise reached out with a problem I hear often. Their cloud costs were climbing, but they had no budget to hire a dedicated FinOps team or to pay for one of the expensive SaaS cost-management platforms on the market.

Their engineering, cloud operations, and SRE teams needed a simple way to understand where the money was going, spot optimization opportunities, and get clear recommendations, without anyone having to become a FinOps specialist first. The request was direct:

“Can we build an AI assistant that understands our cloud environment, answers questions about our costs in plain language, and tells us how to reduce spending whenever the teams need it?”

That question is what led me to build a Cost Optimization Agent on AWS: a conversational interface that lets any engineer ask about cloud spend, see where it is going, and get specific actions to bring it down.

What I Built

The agent answers questions like “Are my costs higher than usual this month?” or “How can I reduce my Lambda spend?” and replies with an analysis and concrete recommendations. It is a single-agent design built from a few clear parts:

  • Claude Sonnet, served through Amazon Bedrock: the model that interprets the question and reasons over the cost data it gets back.
  • Amazon Bedrock AgentCore Runtime: hosts the agent in production and runs its reasoning-and-tool-selection loop, with auto-scaling, session isolation, and monitoring handled for me.
  • Amazon Bedrock Guardrails: content filtering on both the user input and the model output that keeps conversations inside the FinOps scope, blocks prompt injection, and prevents sensitive data from leaking.
  • A set of cost-intelligence tools: each function calls an AWS cost or monitoring API: Cost Explorer, AWS Budgets, Amazon CloudWatch, and AWS Compute Optimizer.
  • A production front door and supporting services: Amazon API Gateway and Amazon Cognito for access, Amazon DynamoDB for conversation context, and Amazon SNS for proactive alerts.

I started from the AWS reference implementation in the awslabs agentcore-samples repository, which gave me the core agent and its cost tools. On top of that, InfrOS — a platform that turns requirements in any form (a simple brief, PRD, design doc, TF, HLD diagram etc.) into a priced, validated cloud design — worked out the production architecture around it, adding the pieces a real deployment needs: 

  • The API Gateway and Cognito front door
  • DynamoDB session persistence
  • SNS alerting
  • Compute Optimizer as a rightsizing source 

so the result is a production setup for the customer rather than the sample running as is. The architecture behind it was designed, priced, and validated with InfrOS: it scored the component options across the priority dimensions, priced each one across on-demand, reserved, and spot, then generated the IaC and emulated it in a sandbox, benchmarking the design against the requirements before any of it reached a real AWS account. What would otherwise take an architect weeks came back as a validated, deployable blueprint in a single session.

Architecture

The system runs in us-east-1 and is organized into three layers. The first is the user interaction layer: engineers type their questions into a lightweight web chat UI whose requests arrive through Amazon API Gateway, where Amazon Cognito authenticates the user, Amazon DynamoDB stores and retrieves the conversation context so sessions persist, and Amazon SNS delivers proactive alerts. The second is the agent core: AgentCore Runtime hosts the agent and runs its reasoning loop with the Claude Sonnet model. The third is the cost-intelligence tools, which read from AWS Cost Explorer, AWS Budgets, Amazon CloudWatch, and AWS Compute Optimizer. Rather than running in the organization's management (payer) account, which AWS recommends reserving for org-wide administration rather than for hosting workloads, the agent runs in a dedicated FinOps tooling account. That account is registered as the delegated administrator for AWS Compute Optimizer and is granted scoped, read-only access to organization-wide Cost Explorer data, so it still reads consolidated cost and rightsizing data across every linked account at the organization level without placing an internet-facing workload in the most sensitive account in the organization. AWS Budgets sits in the global scope rather than the Region, since budgets are account wide.

‍

Amazon Bedrock plays two distinct roles in the design, worth separating because the service name is the same in both. One role is Guardrails, filtering the conversation on the way in and on the way out; the other is the model endpoint that serves Claude Sonnet for the agent’s reasoning. Same service, two different jobs.

‍

The agent itself is inexpensive to run about $479 a month against the customer’s $1,500 budget. For a FinOps tool, the interesting detail is that roughly 86% of that ($412) is the Claude Sonnet inference, not the surrounding infrastructure. The model is the cost to watch, which is a point I come back to under future work.

Architecture Decisions

Each part of the design was a deliberate choice that InfrOS evaluated and scored against the priority profiles, and the trade-offs are worth spelling out. Here is the reasoning behind the main ones.

‍

Why AgentCore Runtime?

‍

The customer wanted a production agent, not a prototype, but had no appetite for managing the infrastructure under it. AgentCore Runtime handles auto-scaling, monitoring, and session isolation, and it deploys through the AgentCore starter toolkit, which provisions the runtime, the IAM execution role, and the container image for you. Session isolation matters when several engineers query cost data at once meaning each conversation stays separate. Using AgentCore Runtime, rather than the managed Agents for Amazon Bedrock feature, kept the agent code under our control while still getting managed hosting.

‍

Why Claude Sonnet?

‍

This agent leans on two things: understanding loosely worded cost questions in plain English, and reasoning over structured billing data to produce a clear recommendation with the trade-offs spelled out. 

‍

Claude Sonnet is strong at both, and its reliability at choosing the right tool from the catalog kept the loop accurate. Serving it through Amazon Bedrock also kept the model inside the customer’s AWS account and security boundary, which was a requirement.

‍

‍So why Guardrails?

‍

A cost assistant should only ever talk about costs. Amazon Bedrock Guardrails enforce that topic boundary on both the user input and the model output, block prompt-injection attempts, and stop sensitive data such as access keys or PII from appearing in a response. Putting safety in a managed, declarative layer kept it separate from the agent logic and applied it consistently to every query.

How It Works

A request follows the same numbered path every time, shown end to end below.

AWS Cost Optimization Agent - Request Flow
  1. An engineer submits a cost question through Amazon API Gateway.
  2. Amazon Cognito authenticates the request.
  3. DynamoDB stores or retrieves the conversation context, so a follow-up keeps its thread.
  4. Bedrock Guardrails validate the query, dropping anything off-topic or unsafe.
  5. The safe prompt is forwarded to AgentCore Runtime, where the agent reasons with the Claude Sonnet foundation model and decides which tools to call:
    1. Rightsizing recommendations from AWS Compute Optimizer.
    2. Cost forecasting from AWS Cost Explorer.
    3. Anomaly detection from Amazon CloudWatch.
    4. Budget monitoring from AWS Budgets.
  6. When something needs attention, CloudWatch and Budgets dispatch alerts through Amazon SNS.
  7. The synthesized answer is returned to the engineer.

The agent does not run a fixed script; the model chooses which tools to call based on the question and may call several before answering. 

‍

The four cost tools map directly to AWS APIs:

  • Cost Anomaly Detection: unusual spending patterns and spikes, detected with Amazon CloudWatch anomaly detection over cost metrics published from Cost Explorer, with alerts dispatched over SNS.
  • Cost Forecasting and Trend Analysis: projected spend and historical trends from AWS Cost Explorer.
  • Service Cost Breakdown: spend by service, account, and resource, combining AWS Compute Optimizer rightsizing data with Cost Explorer to flag unused, underutilized, and oversized resources.
  • Budget Monitoring and Status: utilization and overrun forecasts from AWS Budgets, with alerts dispatched over SNS.

Infrastructure and Deployment

The agent deploys through the AgentCore starter toolkit, wrapped by the repository’s scripts. After cloning the reference repository and installing dependencies, there are three steps, test locally, deploy, then test the deployed agent against live cost data:


# Clone the AWS reference implementation
git clone https://github.com/awslabs/amazon-bedrock-agentcore-samples.git
cd amazon-bedrock-agentcore-samples/02-use-cases/cost-optimization-agent
pip install -r requirements.txt
 
# 1. Run the agent locally against six sample questions
python test_local.py
 
# 2. Provision AWS resources and deploy to AgentCore Runtime
python deploy.py
 
# 3. Exercise the deployed agent with live cost data
python test_agentcore_runtime.py
  

‍

The deploy step calls the starter toolkit, which builds the container image, creates the IAM execution role and ECR repository, and registers the runtime so the agent itself does not need a hand-written infrastructure module. The supporting resources around it (API Gateway, Cognito, DynamoDB, SNS, the Guardrail, and the budget) are defined in Terraform so they are version-controlled and repeatable. The Guardrail, for example, is a short block that also blocks prompt-injection attempts and stops AWS keys from ever appearing in a response:


resource "aws_bedrock_guardrail" "finops" {
  name                      = "finops-cost-agent"
  blocked_input_messaging   = "I can only help with AWS cost and FinOps questions."
  blocked_outputs_messaging = "That response was blocked by policy."
 
  topic_policy_config {
    topics_config {
      name       = "NonFinOps"
      type       = "DENY"
      definition = "Any request not related to AWS cost analysis or optimization."
    }
  }


  content_policy_config {
    filters_config { type = "PROMPT_ATTACK" input_strength = "HIGH" output_strength = "NONE" }
  }
 
  sensitive_information_policy_config {
    pii_entities_config { type = "AWS_ACCESS_KEY" action = "BLOCK" }
    pii_entities_config { type = "AWS_SECRET_KEY" action = "BLOCK" }
  }
}    
  

‍

The Outcome

Before any production rollout, we ran the agent against the customer’s dev and test AWS environment three linked accounts with about $1,012 of spend over the previous 30 days (a window that straddled April and May) to see what it would find. This is the summary it returned:

In a single run it flagged a $115.38 anomaly (EKS extended support, billed April 19–26) and forecast May at $1,023.76, up 13.3% on the full April calendar month of about $904. The $1,012.38 headline is the trailing-30-day total, which runs higher than the April calendar month because that window also caught the EKS spike. Against that roughly $1,012 monthly run rate it identified $369 a month in savings: a 36.5% reduction worth about $4,428 a year. 

‍

To be precise, that is spend the agent recommended cutting rather than money already removed, and on a roughly $1,000-a-month sandbox the $4,428-a-year figure is a proof of capability more than an ROI case: at $479 a month the agent would cost more to run than that. What mattered in the pilot was that it surfaced this much on a tiny environment in a single run, as a summary panel alongside its conversational answers. The ROI argument sits with the production rollout below, where the same engine runs against a far larger bill.

‍

On the strength of that pilot the customer moved the agent into production. Within the first few months, the changes the engineers acted on added up to roughly a 12% reduction in the monthly bill. A good part of that came from one early find: an oversized Amazon RDS instance that Compute Optimizer flagged for rightsizing, alongside a handful of EC2 instances the team had spun up for a project and left running for months after they stopped using them. 

‍

The agent surfaced both in response to a plain question about where the months spend was going, the kind of thing that usually hides in a billing console until someone goes looking.

‍

Just as important was the change in who could ask cost questions and how fast. Engineers no longer waited on a central team or a paid dashboard; they asked in plain language and got an answer with a recommended action, so cost awareness happened during day to day work instead of in a monthly review. Against the production bill, the roughly $479-a-month agent cost a small fraction of the 12% it helped remove, and it met the original constraint of meaningful FinOps coverage without a dedicated team or a third-party platform, which was the whole reason the CIO called in the first place.

Further Improvements and Architecture Vision

The clearest piece of the architecture vision is memory. Today Amazon DynamoDB stores and retrieves the conversation context, which means I am managing session state, retrieval, and expiry myself. I plan to replace it with Amazon Bedrock AgentCore Memory, which provides short-term memory for the active session and long-term memory that persists across sessions as a native capability of the runtime already hosting the agent. That removes a hand-managed store and lets the platform handle what it is built for the same reasoning behind choosing AgentCore Runtime in the first place. DynamoDB would only stay if there were structured, non-conversational records worth keeping.

Conclusion

The Cost Optimization Agent took a request that usually ends in a hire or a software purchase and answered it with a small, focused build instead. Claude Sonnet through Amazon Bedrock supplies the reasoning, Bedrock Guardrails keep it safe and on topic, AgentCore Runtime hosts it and runs the tool loop, and a set of cost tools connect it to Cost Explorer, Budgets, CloudWatch, and Compute Optimizer with API Gateway, Cognito, DynamoDB, and SNS making it a real deployment. The pattern is reusable: give a model a clear set of narrow tools and a safe runtime, and you can put a useful assistant in front of a problem that used to need a whole team. And the build itself was just as lean: InfrOS turned what would have been weeks of architecture work into a single session, exploring and scoring the options and handing back a priced, validated, IaC-ready design.

Keep on reading

Events
Meet InfrOS at AWS re:Invent 2026 in Las Vegas
Guy Brodetzki
Oct 11, 2026
·
6 min read

InfrOS is excited to be exhibiting at AWS re:Invent 2026 in Las Vegas!

We'll be joining the global cloud community to explore how organizations can make better infrastructure decisions, reduce unnecessary cloud spending, and build more secure and resilient environments.

Non-complex fun at Booth #1387

Fun shouldn't be complex at all! Stop by for:

  • Daily raffles and prize giveaways throughout the event.
  • Quick chats with the team and live product demos.

Meet Our Team

Our founders and team members will be at the event to meet cloud architects, engineering leaders, and organizations looking to improve their cloud infrastructure:

Schedule a Meeting with Us

We'd love to connect! Stop by for a quick chat or book a meeting in advance to see InfrOS in action.


Book a Meeting with InfrOS


See you in Las Vegas!

‍

Events
Meet InfrOS at KubeCon + CloudNativeCon North America 2026
Guy Brodetzki
Oct 11, 2026
·
6 min read

November 9–12, 2026 | Salt Lake City, Utah | Booth #360


InfrOS is heading to KubeCon + CloudNativeCon North America 2026! We're looking forward to meeting cloud engineers, platform teams, and technology leaders to discuss how to make cloud infrastructure easier to design, validate, and manage.

What We're Bringing to KubeCon

Modern cloud environments are becoming more complex. Teams need to balance performance, cost, security, and resilience while keeping infrastructure aligned with changing requirements.

At our booth, we'll demonstrate how InfrOS helps teams:

  • Design and compare cloud architectures before deployment.
  • Validate infrastructure decisions across cost, performance, security, and resilience.
  • Generate deployment-ready infrastructure as code (IaC).
  • Continuously evaluate architectures as workloads and requirements evolve with Evolving Architecture™.

Meet Our Team

Our team will be available throughout the event to discuss your infrastructure challenges and demonstrate the InfrOS platform.

Here's our team attending the event:


Find us:
Booth #360, Salt Palace Convention Center, Salt Lake City.

Let's Meet at KubeCon

Have an infrastructure challenge you'd like to discuss? Stop by our booth or schedule a dedicated meeting with our team.


Book a Meeting with InfrOS


See you in Salt Lake City!

‍

AI & Data
Infrastructure for Hybrid LLM Agent Deployments: Architecture Patterns for Production AI
Omer Shafir
Sep 2, 2026
·
6 min read

AI agents are moving from experiments into production. They search internal knowledge, call APIs, write to databases, trigger workflows, and make decisions based on data pulled from many systems. That makes them far more useful than a traditional chatbot, and far harder to run reliably.

The reason is that an agent is not just a model behind an API. A production agent leans on a language model, databases, vector stores, external APIs, GPUs, identity systems, and internal apps. Some of that runs in the cloud, some has to stay on company servers. So the real question is not which model to use. It is where each part runs, how the pieces talk, what happens when one fails, and how it all holds up as usage grows. The architecture decisions around an agent matter more, and last longer, than the model you pick, so the time to make them is before anything is built. That is what building infrastructure for hybrid LLM agent deployments comes down to.

‍

Key Takeaways

  • Planning ahead matters more than the AI tools you pick. A strong model on a poorly planned architecture still ends up unreliable and expensive.
  • AI agent infrastructure is not like normal app infrastructure. A single agent request can search a knowledge base, call several tools, hit multiple data sources, and invoke the model more than once. So instead of a fixed request-and-response path, you have a system that leans on models, data, networks, security, and many services all at the same time. That creates demands around latency, availability, observability, and cost that a standard web app never has to deal with.
  • Hybrid deployments keep sensitive workloads on your own infrastructure while using cloud services where they make sense, but they add real complexity.
  • Testing architecture choices before deployment prevents expensive redesigns later.

Why AI Agents Need Different Infrastructure

A normal app follows a predictable path. A user sends a request, the app reads or writes some data, and sends back a response. An agent is far less predictable.

Ask an agent to help investigate a customer issue and it might search a knowledge base, query a database, call an internal API, ask the model to reason over the results, decide it needs another tool, call that too, then answer and log the whole thing. Every step adds a dependency.

That changes the llm infrastructure requirements for production. The infrastructure has to support the model and everything around it: latency, availability, where sensitive data is allowed to go, what the agent can access, how it scales to thousands of users, what each interaction costs, and whether the team can see why it slowed down or failed. A prototype runs fine on a single endpoint and a laptop. Production has to account for all of it.

‍

What "Hybrid" Means Here

Hybrid just means some of the system runs in the cloud and some runs on your own servers. Teams do this for a few reasons.

Sometimes it is about data. A financial firm might keep customer records in its own environment, let the agent pull them locally, and send only the needed context to a cloud model. Sometimes it is about the split between apps and models, where existing apps and databases stay on internal servers while model inference runs in the cloud and the agent connects the two. And sometimes it is about sensitivity, where routine work runs in the cloud and the most sensitive jobs stay on dedicated hardware.

The thing to remember is that hybrid is not automatically better. It adds networking, security, and operational complexity, so it should be a deliberate choice, driven by what the workload actually needs.

‍

Common Setups Companies Use Today

There is no single right architecture, but a handful of patterns show up again and again:

  • Cloud agent, cloud models. Everything runs in the cloud. Simplest to deploy, with elastic capacity and managed services, but costs climb fast as agents make more model and tool calls.
  • On-prem agent, cloud inference. Orchestration and sensitive data stay internal while the model runs in the cloud. Good for control, but watch network latency and what data gets sent out.
  • Hybrid inference. A small local model handles routine requests and a larger cloud model takes the hard ones. Balances cost and privacy, but routing and capacity planning get trickier.
  • Cloud agent, private data. The agent runs in the cloud but critical databases stay on-prem behind controlled connections. Useful when internal systems can't easily move.
  • Many environments. Big enterprises end up with agents across several clouds, regions, and internal systems. The job shifts from deploying one app to keeping a constantly changing architecture understandable.

Why Planning Ahead Beats Fixing Problems Later

This is where most of the cost hides. Building the first version fast and worrying about architecture later works fine while you are experimenting. It gets expensive in production.

Take an agent handling 100 requests a day. Nobody notices that each one crosses three network boundaries, hits two external services, and calls an expensive model. At 100 requests it is nothing. At 100,000 it is an architecture problem. Resilience works the same way: if the agent quietly depends on a single region, model provider, or database, that one failure takes it all down, and fixing it later means reworking networking, data flows, compute, and security at once.

Architecture decisions compound, so it pays to compare options before you commit: how cost behaves as usage grows, where latency builds up, which components are single points of failure, and what happens when a model endpoint goes dark. This is the shift-left idea applied to infrastructure. Instead of finding the problems after launch, you validate the design before committing to it. We go deeper on this in Shift-Left Cloud Infrastructure Design.

Planning ahead is not about predicting five years out. It is about making the tradeoffs visible before they get expensive, so the choice is deliberate instead of just whatever was easiest to ship first.

‍

Planning for AI Training Infrastructure

Inference is only half the story. Teams that train or fine-tune models face another set of needs, and llm training infrastructure can call for serious GPU capacity, fast networking, big datasets, and careful scheduling. Even here, more hardware is not the fix. What matters is utilization. A common pattern is to keep dedicated GPUs for steady, high-volume work and rent cloud GPUs for occasional bursts. Underused dedicated hardware is just as wasteful as sloppy cloud spend, so plan around real workload behavior, not the theoretical maximum.

‍

FAQ

What makes AI agent infrastructure different from regular app infrastructure?

The big difference is predictability. A normal app runs a fixed path. An agent decides what to do at runtime, so one request may branch across tools, data sources, and repeated model calls. Planning has to cover that variability, plus the latency, security, observability, and cost it brings.

What do companies need to plan for before running AI agents in production?

Plan for model capacity, data access, networking, security, latency, availability, observability, scaling, and cost. Map the critical dependencies and failure scenarios too. The most important step is understanding how the whole architecture behaves under real workloads, not just testing each component on its own.

Can a hybrid setup slow down AI agents?

Yes. Every hop between environments adds latency, especially when an agent keeps moving data between on-prem systems and the cloud. A good hybrid design limits this by keeping components that talk to each other often close together and cutting out unnecessary data movement.

How do companies plan ahead for training large AI models?

Start with workload size, GPU needs, training frequency, storage, networking, and utilization. Then compare dedicated infrastructure, cloud capacity, or a mix. The aim is enough compute for the workloads you actually run, without paying year-round for hardware that mostly sits idle.

‍