Change
ae0a5aa
ae0a5aa778db6c5d49286c3f3d02870094761536 · commit on GitHub
aws-blog-feed: changed (575352 bytes, HTTP 200)
raw/aws-blog-feed/response.xml modified
- Source
- aws-blog-feed
- Lines added
- +794
- Lines removed
- -1,047
- Stored bytes at this commit
- 575,352
- Timestamp
- observed
- Raw artifact at this commit
- raw/aws-blog-feed/response.xml
Recorded headers
| observed_at | 2026-10-31T05:41:20.434Z |
|---|---|
| origin_date | null |
| status | 200 |
| final URL | https://aws.amazon.com/blogs/machine-learning/feed/ |
| etag | null |
| last-modified | Sat, 31 Oct 2026 02:20:49 GMT |
| date | Sat, 31 Oct 2026 05:41:20 GMT |
| age | null |
| cache-control | null |
| cf-cache-status | null |
| content-encoding | null |
| content-length | null |
@
@@ -5,7 +5,7 @@ <atom:link href="https://aws.amazon.com/blogs/machine-learning/feed/" rel="self" type="application/rss+xml"/> <link>https://aws.amazon.com/blogs/machine-learning/</link> <description>Official Machine Learning Blog of Amazon Web Services</description>-
<lastBuildDate>Thu, 29 Oct 2026 20:16:40 +0000</lastBuildDate>+
<lastBuildDate>Fri, 30 Oct 2026 22:42:24 +0000</lastBuildDate> <language>en-US</language> <sy:updatePeriod> hourly </sy:updatePeriod>@
@@ -13,6 +13,799 @@ 1 </sy:updateFrequency> <item>+
<title>Managing Amazon Bedrock costs end to end: A playbook for FinOps and platform teams</title>+
<link>https://aws.amazon.com/blogs/machine-learning/managing-amazon-bedrock-costs-end-to-end-a-playbook-for-finops-and-platform-teams/</link>+
+
<dc:creator><![CDATA[Aswath Ram A Srinivasan]]></dc:creator>+
<pubDate>Fri, 30 Oct 2026 22:42:24 +0000</pubDate>+
<category><![CDATA[Advanced (300)]]></category>+
<category><![CDATA[Amazon Bedrock]]></category>+
<category><![CDATA[Technical How-to]]></category>+
<guid isPermaLink="false">5542e879e541b56f1c06a9f2c71c7c3f37f6d5e3</guid>+
+
<description>This post presents a five-stage operating model for managing Amazon Bedrock cost: attribute every dollar to an owner, make every request observable, enforce budgets, optimize platform defaults, and operate a review cadence. Written for FinOps and platform engineering teams.</descri…+
<content:encoded><p>Cost management for generative AI is a shared responsibility between the teams that build applications and the teams accountable for cloud spend. Many teams start by comparing per-model token rates and asking application teams to shorten prompts. Those steps help,…+
<p>Agentic workloads make those questions more pressing. A conversational assistant typically issues one model invocation per user turn. An agentic workflow, such as an AI coding assistant that plans a change, reads files, calls tools, and iterates, issues many invocations per task and carries…+
<p>The fix isn’t a cheaper model or a smaller prompt. It’s an operating model: a repeatable loop that attributes every dollar to an owner, makes every request observable, alerts on and enforces budgets before overspend compounds, optimizes the platform defaults that drive most waste, and revie…+
<p>In this post, you learn how to manage <a href="https://aws.amazon.com/bedrock/" target="_blank" rel="noopener">Amazon Bedrock</a> cost in five steps. You attribute every dollar to an owner, make every request observable, control spend with budgets and enforcement, optimize the p…+
<h2 id="the-operating-model-in-one-view">The operating model in one view</h2> +
<p>Five stages, run as a loop. Attribute: every Amazon Bedrock dollar lands on an identity, team, and application in the billing pipeline. Observe: every request is logged with enough metadata to explain what generated the spend. Enforce: budgets have teeth, with alerts at minimum and hard blo…+
<div style="width: 810px" class="wp-caption alignnone">+
<a href="https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2026/10/29/ML-21654-1-1.png" target="_blank" rel="noopener"><img src="https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2026/10/29/ML-21654-1-1.png" alt="Five-stage Amazon B…+
<p class="wp-caption-text">Figure 1: The five-stage operating model, run as a continuous loop</p>+
</div> +
<h2 id="stage-1-attribute-every-dollar">Stage 1: Attribute every dollar</h2> +
<p>You can’t manage what you can’t attribute, and everything downstream (chargeback, budgets, enforcement, anomaly detection) depends on this stage. The foundation is the granular cost attribution of Amazon Bedrock (see <a href="https://aws.amazon.com/blogs/machine-learning/introducing-gran…+
<p>Setup is four steps:</p> +
<ol type="1"> +
<li>Turn on IAM principal data in your CUR 2.0 data export.</li> +
<li>Tag your IAM principals with business dimensions such as team, application, and cost center. For federated access, configure your identity provider to pass session names and tags through OIDC or SAML claims.</li> +
<li>Activate those tags as cost allocation tags in AWS Billing (console or the <code>UpdateCostAllocationTagsStatus</code> API).</li> +
<li>Analyze the tags: they surface in CUR 2.0 with an <code>iamPrincipal/</code> prefix (for example, <code>iamPrincipal/team</code>) and appear in <a href="https://aws.amazon.com/aws-cost-management/aws-cost-explorer/" target="_blank" rel="noopener">AWS Cost Exp…+
</ol> +
<p>This is invoice-grade, per-identity attribution with no custom infrastructure.</p> +
<h3 id="the-shared-role-problem">The shared-role problem</h3> +
<p>The pattern that deserves the most attention is the shared-role problem, because it is where most platforms silently lose attribution. A large language model (LLM) gateway that calls Amazon Bedrock through a single IAM role attributes every dollar to that one role, eliminating per-user visi…+
<p>This needs two roles: a gateway execution role holding <code>sts:AssumeRole</code> and <code>sts:TagSession</code> permissions, and the Amazon Bedrock invocation role it assumes. The result is <code>line_item_iam_principal</code> entries like <code>…+
<div class="hide-language"> +
<pre><code class="language-python">import boto3+
+
sts = boto3.client("sts")+
+
# One call per user; cache the returned credentials up to 1 hour+
response = sts.assume_role(+
RoleArn="arn:aws:iam::123456789012:role/BedrockRuntimeRole",+
RoleSessionName="gw-alex", # the user, not the gateway+
Tags=[+
{"Key": "team", "Value": "sales-ai"},+
{"Key": "application", "Value": "renewal-agent"},+
{"Key": "costCenter", "Value": "CC-2041"}+
]+
)</code></pre> +
</div> +
<h3 id="a-note-on-application-inference-profiles-and-projects">A note on application inference profiles and Projects</h3> +
<p>Amazon Bedrock offers two more attribution mechanisms, each suited to a different pattern. <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-create.html" target="_blank" rel="noopener">Application inference profiles</a> are pre-created, per-applica…+
<p>For <code>bedrock-runtime</code> workloads, we recommend IAM principal attribution through session tags as the primary mechanism. It scales with your identity system, requires no pre-created resources, and covers every model and API operation. Application inference profiles work…+
<h2 id="stage-2-make-every-request-observable">Stage 2: Make every request observable</h2> +
<p>CUR tells you who spent. Invocation logs tell you what happened. Amazon Bedrock supports <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/model-invocation-logging.html" target="_blank" rel="noopener">model invocation logging</a> of request data, response data, and m…+
<p>Logging also closes the latency gap: CUR attribution lags roughly 24 hours, but CloudWatch plus OpenTelemetry can power near-real-time dashboards showing per-developer spend within minutes (<a href="https://aws.amazon.com/blogs/mt/analyzing-claude-code-usage-with-cloudwatch-and-opentelem…+
<h3 id="request-metadata-for-workload-level-attribution">Request metadata for workload-level attribution</h3> +
<p>Raw logs answer identity-level questions. To answer workload-level questions (which feature, workflow, or tenant generated the tokens), stamp <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html#bedrock-runtime_Converse-request-requestMetadata" targe…+
<p>The following example uses Anthropic Claude Sonnet 5.5 on Amazon Bedrock through the US cross-Region inference profile. For the full list of models, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html" target="_blank" rel="noopener">Supported founda…+
<div class="hide-language"> +
<pre><code class="language-python">response = client.converse(+
modelId="us.anthropic.claude-sonnet-5-5",+
messages=[...],+
requestMetadata={+
"application": "renewal-copilot",+
"workflow": "renewal-risk-summary",+
"tenant": "enterprise-sales",+
"agent": "renewal-agent"+
}+
)</code></pre> +
</div> +
<p>Amazon Bedrock doesn’t enforce request metadata, and teams drift into inconsistent schemas quickly when every application does its own thing. The platform team should inject mandatory metadata centrally in a shared SDK wrapper or gateway, normalize the key set, and treat metadata coverage a…+
<h3 id="diagnostic-queries">Diagnostic queries</h3> +
<p>With logs and metadata in place, CloudWatch Logs Insights answers the standing questions. <em>Who consumes the most tokens</em>:</p> +
<div class="hide-language"> +
<pre><code class="language-plaintext">fields @timestamp, identity.arn as caller, modelId,+
input.inputTokenCount as inTokens,+
output.outputTokenCount as outTokens+
| stats sum(inTokens + outTokens) as totalTokens,+
count(*) as calls+
by caller, modelId+
| sort totalTokens desc+
| limit 25</code></pre> +
</div> +
<p>The same query grouped by <code>requestMetadata.application</code> and <code>requestMetadata.workflow</code> instead of <code>caller</code> produces the workload-level leaderboard: the view product and engineering teams will ask FinOps for the moment char…+
<p><strong>Note:</strong> Field paths shown in the preceding query are illustrative. Verify against your invocation log schema, which may vary by model, API operation, and logging configuration.</p> +
<h2 id="stage-3-enforce-budgets">Stage 3: Enforce budgets</h2> +
<p>With attribution and observability in place, enforcement becomes an architecture choice rather than a wish. There are three viable tiers. The right one depends on your spend velocity, your risk tolerance for overspend, and how your tools connect to Amazon Bedrock.</p> +
<h3 id="tier-1-monitor-and-alert-no-blocking">Tier 1: Monitor and alert (no blocking)</h3> +
<p>Amazon Bedrock writes principal identity into the billing pipeline automatically. You put AWS Budgets on top for threshold alerts, with the OpenTelemetry dashboards from Stage 2 closing the 24-hour CUR gap for day-to-day visibility. Nothing to deploy, native AWS billing, and no added latenc…+
<h3 id="tier-2-iam-tag-enforcement-deny-on-breach">Tier 2: IAM tag enforcement (deny on breach)</h3> +
<p>An aggregator AWS Lambda function tallies per-user token and dollar counters in Amazon DynamoDB from invocation log data. When a user breaches their threshold, the function adds their identity to a shared IAM deny policy (denying <code>bedrock:*</code>) until a monthly reset or …+
<h3 id="tier-3-gateway-enforcement-synchronous-block">Tier 3: Gateway enforcement (synchronous block)</h3> +
<p>A gateway sits in the inference data path and enforces budgets synchronously, returning HTTP 429 the moment a user or team exceeds their limit. You get sub-second blocking, per-user model allowlists, token rate limits, and centrally enforced routing rules. The trade-off: a component in the …+
<p>For Claude Code and Claude Desktop fleets, the <a href="https://aws.amazon.com/blogs/machine-learning/introducing-claude-apps-gateway-for-aws/" target="_blank" rel="noopener">Claude apps gateway for AWS</a> is the official recommendation. It ships inside the CLI binary and runs …+
<h3 id="choosing-a-tier">Choosing a tier</h3> +
<p>Two factors dominate.</p> +
<p><strong>Connectivity:</strong> If developers call Amazon Bedrock directly with no proxy, only Tiers 1 and 2 are viable.</p> +
<p><strong>Spend velocity:</strong> If spend is already in the millions per month, build enforcement now. If alerts can hold the line for another quarter, invest in Stages 1 and 2 first and add enforcement when the data demands it.</p> +
<p>Most organizations should phase it: observe at Tier 1, then step up. Treat all three as bridges, not destinations: the <a href="https://docs.aws.amazon.com/wellarchitected/latest/agentic-ai-lens/agentcost07.html" target="_blank" rel="noopener">Well-Architected Agentic AI Lens</a>…+
<h2 id="stage-4-optimize-the-defaults">Stage 4: Optimize the defaults</h2> +
<p>Most Amazon Bedrock waste is not individual carelessness. It is platform defaults nobody set. The two highest-impact levers are both platform-controlled.</p> +
<h3 id="model-routing">Model routing</h3> +
<p>Not every task needs a frontier model. Routine completions (boilerplate, linting suggestions, small refactors) can run on smaller, cheaper models with quality reserved for complex reasoning, through <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/intelligent-prompt-routing.…+
<h3 id="prompt-caching">Prompt caching</h3> +
<p>Prompt caching rewards stable repeated prefixes. As of October 2026, the published <a href="https://aws.amazon.com/bedrock/pricing/" target="_blank" rel="noopener">Amazon Bedrock pricing</a> for Anthropic Claude models in US East (N. Virginia) bills a cache write at 1.25x the ba…+
<p>Candidates surface directly from the invocation logs:</p> +
<div class="hide-language"> +
<pre><code class="language-plaintext">fields requestMetadata.workflow as workflow, modelId,+
input.inputTokenCount as inTokens+
| stats count(*) as calls,+
avg(inTokens) as avgInputTokens,+
sum(inTokens) as totalInputTokens+
by workflow, modelId+
| filter calls &gt; 50 and avgInputTokens &gt; 2000+
| sort totalInputTokens desc+
| limit 25</code></pre> +
</div> +
<p><strong>Note:</strong> Field paths shown in the preceding query are illustrative. Verify against your invocation log schema, which may vary by model, API operation, and logging configuration.</p> +
<h3 id="application-level-optimization">Application-level optimization</h3> +
<p>A third class of savings (just-in-time retrieval instead of stuffed context, compaction of long conversations, distilling stable high-volume workflows onto smaller models) belongs to application teams rather than the platform. The platform’s job is to make those savings visible: publish the…+
<h2 id="stage-5-operate-the-loop">Stage 5: Operate the loop</h2> +
<p>The first four stages produce data. This one turns it into decisions. The platform team runs a standing health dashboard with four signals:</p> +
<ul> +
<li><strong>Model mix:</strong> Which models are called and how often, the direct measure of routing discipline.</li> +
<li><strong>Failed request rates:</strong> Errors, throttles, and timeouts. Each retry adds latency, and a client-side timeout on a request that still completes on the service side can be billed twice, once for the abandoned call and once for the retry.</li> +
<li><strong>Cache effectiveness:</strong> The read-versus-write ratio from Stage 4.</li> +
<li><strong>Metadata coverage:</strong> The percentage of production calls with complete metadata. Every uncovered call is an attribution blind spot that quietly degrades every other number.</li> +
</ul> +
<p>When a signal drifts, the remediation is a policy change (routing rules, token limits, metadata enforcement), not an email asking teams to be careful.</p> +
<h3 id="the-money-loop">The money loop</h3> +
<p>FinOps runs the money loop on the same data. When attribution is clean, anomaly detection becomes an investigation stream rather than a panicked all-hands: a spike in a tagged team or application triggers a lookup in the Stage 2 leaderboard, not a war room. Chargeback runs from CUR grouping…+
<h3 id="scorecard">Scorecard</h3> +
<p>The following thresholds are starting points, not prescriptions. Calibrate them against your own fleet data and pricing tier before adopting them as policy.</p> +
<table border="1px" width="100%" cellpadding="10px"> +
<tbody> +
<tr> +
<td><strong>Dimension</strong></td> +
<td><strong>Metric</strong></td> +
<td><strong>Green</strong></td> +
<td><strong>Yellow</strong></td> +
<td><strong>Red</strong></td> +
</tr> +
<tr> +
<td><strong>Unit economics</strong></td> +
<td>Cost per successful outcome</td> +
<td>≤ budget</td> +
<td>1–1.5x budget</td> +
<td>&gt;1.5x budget</td> +
</tr> +
<tr> +
<td><strong>Per-dev cost</strong></td> +
<td>Daily spend per developer</td> +
<td>&lt;$100</td> +
<td>$100–$300</td> +
<td>&gt;$300</td> +
</tr> +
<tr> +
<td><strong>Model routing</strong></td> +
<td>% of calls to cost-efficient-models</td> +
<td>&gt;50%</td> +
<td>30–50%</td> +
<td>&lt;30%</td> +
</tr> +
<tr> +
<td><strong>Cache efficiency</strong></td> +
<td>Cache-read hit ratio</td> +
<td>&gt;60%</td> +
<td>30–60%</td> +
<td>&lt;30%</td> +
</tr> +
</tbody> +
</table> +
<p>Green means the workload operates inside its economic envelope. Yellow means routing or caching discipline is slipping. Red means spend is concentrating in premium models or uncached context, and the Stage 3 and 4 controls are the remediation path. Review this scorecard on a regular cadence…+
<h2 id="conclusion">Conclusion</h2> +
<p>In this post, you learned how to build a five-stage operating model that takes Amazon Bedrock spend from uncontrolled to fully governed:</p> +
<ol type="1"> +
<li><strong>Attribute</strong> every dollar to an owner using IAM principal tags, session tags, and CUR 2.0.</li> +
<li><strong>Observe</strong> every request through model invocation logging and stamped request metadata.</li> +
<li><strong>Enforce</strong> budgets at the tier that matches your risk: monitor-only, IAM deny on breach, or synchronous gateway blocking.</li> +
<li><strong>Optimize</strong> platform defaults with intelligent prompt routing and prompt caching to remove waste centrally.</li> +
<li><strong>Operate</strong> a scorecard and review cadence that turns telemetry into policy decisions.</li> +
</ol> +
<p>Notice the first row of that scorecard: cost per successful outcome, not cost per call. That distinction is where this playbook hands off. Everything here makes Amazon Bedrock spend visible, attributable, capped, and efficient, but a workflow can be perfectly efficient and still not be wort…+
<p>Build the five stages and you can answer, end to end: who spent it, why, and whether it was controlled. That is what it means to manage Amazon Bedrock cost, and it is the difference between a monthly bill review and an operating model.</p> +
<p>To get started, deploy the <a href="https://github.com/aws-solutions-library-samples/guidance-for-claude-code-with-amazon-bedrock" target="_blank" rel="noopener">Guidance for Claude Code with Amazon Bedrock</a> reference architecture for Stages 1–3, then use the <a href="http…+
<p>&nbsp;</p> +
<hr style="width: 100%"> +
<h2>About the authors</h2> +
<footer> +
<div class="blog-author-box" style="padding-top: 2.0em"> +
<div class="blog-author-image" style="margin-right: 1.0em">+
<img loading="lazy" class="alignnone size-full" src="https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2026/10/30/ml-21654-aswath.jpeg" alt="Aswath Ram A Srinivasan" width="100" height="133">+
</div> +
<h3 class="lb-h4">Aswath Ram A Srinivasan</h3> +
<p style="overflow: hidden">Aswath is a Senior Specialist Solutions Architect for Amazon Bedrock, focusing on core models, features, and cost optimization and attribution. He helps ISVs and strategic customers solve their challenges on Amazon Bedrock. He works with enterprise teams to design…+
</div> +
<div class="blog-author-box" style="padding-top: 2.0em"> +
<div class="blog-author-image" style="margin-right: 1.0em">+
<img loading="lazy" class="alignnone size-full" src="https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2026/10/29/ML-21654-3-1.jpg" alt="Aamna Najmi" width="100" height="133">+
</div> +
<h3 class="lb-h4">Aamna Najmi</h3> +
<p style="overflow: hidden">Aamna is a Senior Specialist Solutions Architect for Generative AI focusing on Anthropic models and operationalizing and governing generative AI systems at scale on Amazon Bedrock. She helps ISVs solve their challenges, embrace innovation, and create new business …+
</div> +
<div class="blog-author-box" style="padding-top: 2.0em"> +
<div class="blog-author-image" style="margin-right: 1.0em">+
<img loading="lazy" class="alignnone size-full" src="https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2026/10/30/ml-21654-ajit.png" alt="Ajit Mahareddy" width="100" height="133">+
</div> +
<h3 class="lb-h4">Ajit Mahareddy</h3> +
<p style="overflow: hidden">Ajit is an experienced Product and Go-To-Market (GTM) leader with over 20 years of experience in product management, engineering, and go-to-market. Prior to his current role, Ajit led product management building AI/ML products at leading technology companies, incl…+
</div> +
<div class="blog-author-box" style="padding-top: 2.0em"> +
<div class="blog-author-image" style="margin-right: 1.0em">+
<img loading="lazy" class="alignnone size-full" src="https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2026/10/29/ML-21654-5-1.jpg" alt="Benedict Augustine" width="100" height="133">+
</div> +
<h3 class="lb-h4">Benedict Augustine</h3> +
<p style="overflow: hidden">Benedict is an adverse Product GTM leader who has been working with top tier ISV for Amazon Bedrock usage.</p> +
</div> +
</footer></content:encoded>+
+
+
+
</item>+
<item>+
<title>Preview web apps live as your coding agent builds them with Amazon Bedrock AgentCore runtime</title>+
<link>https://aws.amazon.com/blogs/machine-learning/preview-web-apps-live-as-your-coding-agent-builds-them-with-amazon-bedrock-agentcore-runtime/</link>+
+
<dc:creator><![CDATA[Sundar Raghavan]]></dc:creator>+
<pubDate>Fri, 30 Oct 2026 21:40:03 +0000</pubDate>+
<category><![CDATA[Advanced (300)]]></category>+
<category><![CDATA[Amazon Bedrock AgentCore]]></category>+
<category><![CDATA[Announcements]]></category>+
<guid isPermaLink="false">f7fa53db3341459d6a27841fb8632835488a9c38</guid>+
+
<description>Amazon Bedrock AgentCore Session endpoints give each runtime session an authenticated URL that forwards any HTTP method, path, and WebSocket connection to the ports you allow. In this post, you deploy a coding agent that keeps a Vite website running in its session, then watch the l…+
<content:encoded><p>Coding agents now build working web apps: a dashboard, a product page, a prototype that a product team wants to try. The fastest way to review that work is to open the app, use it, ask for a change, and check the result. That loop works well when the app keeps run…+
<p><a href="https://aws.amazon.com/bedrock/agentcore/" target="_blank" rel="noopener">Amazon Bedrock AgentCore</a> is a platform to build, connect, and optimize agents at scale, with your choice of agent framework and foundation model (FM). <a href="https://docs.aws.amazon.com/b…+
<p>In this post, you deploy a coding agent that keeps a Vite website running in its session, then open one local page with a chat on the left and the live website on the right. You ask the agent to switch the site to a dark color theme, follow its steps as they stream in, and watch the website…+
<p>The complete sample, including the notebook this post follows, is in the <a href="https://github.com/awslabs/agentcore-samples/tree/main/01-features/02-host-your-agent/01-runtime/03-advanced/16-session-endpoints" target="_blank" rel="noopener">14-remote-access folder</a> of the …+
<h2 id="how-session-endpoints-work">How Session endpoints work</h2> +
<p>Each session gets its own Session endpoint, and six details shape how you use it.</p> +
<p><strong>You choose which ports it reaches.</strong>&nbsp;You set <code>allowedPorts</code> when you call <a href="https://docs.aws.amazon.com/bedrock-agentcore-control/latest/APIReference/API_CreateAgentRuntime.html" target="_blank" rel="noopener">CreateAge…+
<p><strong>The URL arrives with the session.</strong> The <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/APIReference/API_InvokeAgentRuntime.html" target="_blank" rel="noopener">InvokeAgentRuntime</a> response carries it in the <code>X-Amzn-Bedrock-…+
<p><strong>Every request is authenticated.</strong> For a runtime that uses <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html" target="_blank" rel="noopener">AWS Identity and Access Management (IAM)</a>, each HTTP request, HTTP/2 stream, and We…+
<p><strong>The host name selects the port.</strong> Your client connects on port 443 regardless of the target port, and a prefix on the host name chooses the port inside the session:</p> +
<div class="hide-language"> +
<pre><code class="language-text">https://8090--&lt;session-endpoint-id&gt;.runtime.bedrock-agentcore.&lt;region&gt;.on.aws/index.html+
https://8081--&lt;session-endpoint-id&gt;.runtime.bedrock-agentcore.&lt;region&gt;.on.aws/status</code></pre> +
</div> +
<p><strong>It carries the protocols your server speaks.</strong> HTTP/1.1 and HTTP/2 requests, including server-sent events and gRPC, and WebSocket connections all pass through. This walkthrough uses HTTP/1.1 and WebSocket.</p> +
<p><strong>It’s scoped to one session.</strong> The URL needs credentials on every request and lasts only as long as the session, so use it to build, test, and review what your agent produces. To serve an app to your users, deploy it to a hosting service such as <a href="https:/…+
<p>A browser can’t add a SigV4 signature or a bearer token to the requests a page makes on its own, so the Session endpoint client in the <a href="https://github.com/aws/bedrock-agentcore-sdk-python" target="_blank" rel="noopener">bedrock-agentcore SDK</a> can open a local endpoint…+
<p>A Session endpoint is different from a <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/agent-runtime-versioning.html" target="_blank" rel="noopener">runtime endpoint</a>, which AgentCore runtime already provides. Use a runtime endpoint, such as <code>…+
<h2 id="solution-overview">Solution overview</h2> +
<p>The sample has four parts. A coding agent runs in the session on port 8080 and edits the website’s files with four tools: list, read, write, and edit. The agent starts a <a href="https://vite.dev/" target="_blank" rel="noopener">Vite</a> development server on port 8090, which se…+
<div style="width: 810px" class="wp-caption alignnone">+
<a href="https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2026/10/28/ML-22062-1.png" target="_blank" rel="noopener"><img src="https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2026/10/28/ML-22062-1.png" alt="Architecture diagram: t…+
<p class="wp-caption-text">Figure 1: Solution architecture</p>+
</div> +
<p>Before step 1, <code>PreviewApp</code> has already called <code>InvokeAgentRuntime</code> once to start the session, which starts the agent and the Vite development server. <code>PreviewApp</code> read the Session endpoint URL from that response and opene…+
<ol type="1"> +
<li>The site pane of the preview page loads the website from the local endpoint on <code>localhost:8088</code>. The local endpoint adds your credentials to each request and the WebSocket handshake, and forwards them to the Session endpoint. The<strong> Session endpoint </…+
<li>You send a prompt from the chat pane. <code>PreviewApp</code> sends it to <code>InvokeAgentRuntime</code> as a standard AWS API call signed with your AWS credentials, and the runtime delivers it to the agent on port 8080. The agent’s steps stream back to the chat p…+
<li>The agent calls Claude Haiku 5.5 in Amazon Bedrock to decide what to change.</li> +
<li>The agent reads the site’s files and saves the ones it changes. The Vite development server serves those files and watches them for changes.</li> +
<li>When a file is saved, Vite pushes the change over the WebSocket opened in step 1, back through the Session endpoint and the local endpoint, and the site pane updates without a refresh.</li> +
<li>From the notebook, <code>PreviewApp</code> reads the agent’s <code>/status</code> route on port 8081 through the same Session endpoint. Only the port changes.</li> +
</ol> +
<p>Port 8080 isn’t in <code>allowedPorts</code>, because <code>InvokeAgentRuntime</code> reaches the agent without going through the Session endpoint.</p> +
<h2 id="prerequisites">Prerequisites</h2> +
<p>To follow the walkthrough, you need:</p> +
<ul> +
<li>An AWS account in an AWS Region where AgentCore runtime Session endpoints are available, with credentials configured.</li> +
<li>Permissions to create an AWS Identity and Access Management (IAM) role, upload to <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html" target="_blank" rel="noopener">Amazon Simple Storage Service (Amazon S3)</a>, and create a runtime, plus <code>b…+
<li>Python 3.10 or later, with <code>bedrock-agentcore</code> 1.25.2 or later and <code>boto3</code> 1.43.122 or later.</li> +
<li><a href="https://git-scm.com/" target="_blank" rel="noopener">Git</a>, to clone the sample repo, and a <a href="https://jupyter.org/" target="_blank" rel="noopener">Jupyter</a> environment, such as JupyterLab or Visual Studio Code with the Jupyter extension, to run…+
<li>Access to <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/model-card-anthropic-claude-haiku-5-5.html" target="_blank" rel="noopener">Claude Haiku 5.5</a> in Amazon Bedrock. For model availability by Region, refer to <a href="https://docs.aws.amazon.com/bedrock…+
<li><a href="https://nodejs.org/" target="_blank" rel="noopener">Node.js</a> 22 or later with <code>npm</code>, which the deployment script uses to package the agent and the website.</li> +
</ul> +
<p>The sample deploys the agent as a zip file in Amazon S3 with <a href="https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-get-started-code-deploy-node.html" target="_blank" rel="noopener">direct code deployment for Node.js</a>, so you don’t need Docker or an &l…+
<h2 id="deploy-the-agent-and-its-website">Deploy the agent and its website</h2> +
<p>First, you deploy the runtime, and the configuration you choose here decides which ports the Session endpoint can reach. The deployment script bundles the agent into one file, adds the website and its dependencies for the runtime’s Linux on Arm64 system, uploads the zip to Amazon S3, and cr…+
<p>The following excerpt from <code>deploy.py</code> shows the two settings that matter for this post. <code>protocolConfiguration</code> says where the agent listens for <code>InvokeAgentRuntime</code>, and <code>allowedPorts</code> lists the po…+
<div class="hide-language"> +
<pre><code class="language-python">agentRuntimeArtifact={"codeConfiguration": {+
"code": {"s3": {"bucket": code_bucket(), "prefix": S3_PREFIX}},+
"runtime": "NODE_22",+
"entryPoint": ["app.js"],+
}},+
protocolConfiguration={"serverProtocol": "HTTP", "port": 8080, "path": "/invocations"},+
allowedPorts=[{"port": 8090}, {"port": 8081}],</code></pre> +
</div> +
<p>The website’s Vite configuration makes the development server reachable from the Session endpoint. It listens on <code>0.0.0.0</code> at port 8090 and doesn’t restrict the <code>Host</code> header (<code>server.allowedHosts</code> is true), because reques…+
<p>To deploy the runtime:</p> +
<p>1. Clone the sample repo and change to the sample folder:</p> +
<div class="hide-language"> +
<pre><code class="language-bash">git clone https://github.com/awslabs/agentcore-samples.git+
cd agentcore-samples/01-features/02-host-your-agent/01-runtime/03-advanced/16-session-endpoints</code></pre> +
</div> +
<p>2. Open <code>session_endpoints_preview.ipynb</code> from the sample folder.</p> +
<p>3. Run the install cell, which installs the Python dependencies.</p> +
<p>4. Run the %run <code>deploy.py</code> cell. Deployment takes a few minutes, mostly waiting for the runtime to reach the <code>READY</code> status.</p> +
<h2 id="open-the-preview">Open the preview</h2> +
<p>With the runtime ready, you start the preview. One call does three things: it starts a session (which starts the website), opens a local endpoint for port 8090, and serves the preview page on <code>localhost:8087</code>.</p> +
<div class="hide-language"> +
<pre><code class="language-python">from preview_app import PreviewApp+
+
app = PreviewApp().start()+
print("Open", app.url)</code></pre> +
</div> +
<p>Inside <code>start()</code>, the calls that use Session endpoints are short. The first <code>InvokeAgentRuntime</code> call returns the URL in a response header, <code>session_endpoint_url</code> reads it, and the Session endpoint client opens a local end…+
<div class="hide-language"> +
<pre><code class="language-python">answer = client.invoke_agent_runtime(+
agentRuntimeArn=runtime_arn, runtimeSessionId=session_id,+
payload=json.dumps({"prompt": ""}).encode(), contentType="application/json",+
)+
endpoint = client.session_endpoint_client(session_endpoint_url(answer))+
local = endpoint.open_local_endpoint(port=8090, local_port=8088).start()</code></pre> +
</div> +
<p>To open the preview:</p> +
<ol type="1"> +
<li>Run the cell that starts <code>PreviewApp</code>.</li> +
<li>Open the printed link, <code>http://localhost:8087</code>, in your browser.</li> +
</ol> +
<p>The page shows the website on the right, served from port 8090 in the session, and a short guide with suggested requests on the left.</p> +
<h2 id="ask-the-agent-for-a-change">Ask the agent for a change</h2> +
<p>Now you ask for a change and watch it arrive. Each prompt goes to the agent through <code>InvokeAgentRuntime</code>. The agent reads the files it needs, writes the ones it changes, and reports each step as it happens. When a file is saved, the Vite development server pushes the …+
<p>To ask for a change:</p> +
<ol type="1"> +
<li>On the preview page, choose <strong>Switch this website to a dark coffee-house color theme</strong>.</li> +
<li>Follow the agent’s steps in the chat pane as it reads and saves files.</li> +
<li>Watch the site pane. It changes when the agent saves the stylesheet, and a banner names the file the change came from.</li> +
</ol> +
<p>The following video shows the preview page while the agent works through several requests. Choosing a suggested request sends it to the agent, the chat pane lists each file the agent reads and saves, and the site pane on the right updates without a refresh, from the dark theme to a green Or…+
<div style="width: 810px" class="wp-caption alignnone">+
<a href="https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2026/10/28/ML-22062-2.gif" target="_blank" rel="noopener"><img src="https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2026/10/28/ML-22062-2.gif" alt="The preview page with a…+
<p class="wp-caption-text">Figure 2: The preview page as the agent works</p>+
</div> +
<p>The steps stream because the agent answers with server-sent events when you ask it to. You can send the same prompts from Python with <code>app.ask</code>, which reads the stream with <code>iter_events</code> from the <code>bedrock-agentcore</code> SDK. T…+
<div class="hide-language"> +
<pre><code class="language-python">for event in app.ask("Make the Order ahead button green"):+
if "step" in event:+
print(" ", event["step"])+
elif "done" in event:+
print(event["done"]["reply"])</code></pre> +
</div> +
<p>The output of this Python script should resemble the following:</p> +
<div class="hide-language"> +
<pre><code class="language-text"> Looking at the site's files+
Reading src/main.js+
Reading src/style.css+
Reading index.html+
Saved src/style.css+
The Order ahead button is now green instead of brown, with white text kept for contrast. You can see it in the hero section, just below the "Small batch coffee, roasted every morning" heading at the top of the page.</code></pre> +
</div> +
<h2 id="reach-a-second-port-in-the-same-session">Reach a second port in the same session</h2> +
<p>The website isn’t the only server you can reach. The agent serves <code>/status</code> on port 8081, which lists each prompt and the files it changed. The same Session endpoint reaches it, and the only difference is the port argument.</p> +
<div class="hide-language"> +
<pre><code class="language-python">status = app.endpoint.request("GET", "/status", port=8081)+
print("GET /status on port 8081: HTTP", status.status)+
for edit in status.json()["edits"]:+
print(" ", edit["prompt"], "-&gt;", ", ".join(edit["files"]))</code></pre> +
</div> +
<p>The output of this Python script should resemble the following:</p> +
<div class="hide-language"> +
<pre><code class="language-text">GET /status on port 8081: HTTP 200+
Make the Order ahead button green -&gt; src/style.css</code></pre> +
</div> +
<h2 id="what-the-session-endpoint-refuses">What the Session endpoint refuses</h2> +
<p>When the runtime refuses a request, it answers with an HTTP status, an empty body, and an error code in a response header, so you can tell its refusals from errors your application returns. The notebook sends a request to a port outside allowedPorts and a request without credentials, and th…+
<p>The following table lists the refusals you’re likely to meet while you build with <strong>Session endpoints</strong>.</p> +
<table border="1px" width="100%" cellpadding="10px"> +
<tbody> +
<tr> +
<td><strong>Request</strong></td> +
<td><strong>Response from the runtime</strong></td> +
</tr> +
<tr> +
<td>A port that isn’t in <code>allowedPorts</code></td> +
<td><code>403 AccessDenied</code></td> +
</tr> +
<tr> +
<td>A request without valid credentials</td> +
<td><code>403 AccessDenied</code> or <code>401 AuthenticationRequired</code></td> +
</tr> +
<tr> +
<td>An allowed port with nothing listening on it</td> Diff display stops at 400 lines. The line counts above are from the whole diff. 63 lines shown here cut at 300 characters. The raw artifact at this commit is linked above.