Coding brokers now construct working net apps: a dashboard, a product web page, a prototype {that a} product staff needs to attempt. The quickest strategy to evaluation that work is to open the app, use it, ask for a change, and verify the consequence. That loop works nicely when the app retains working the place the agent edits it, so every change reveals up within the browser inside seconds. When the app should be copied out and deployed some place else first, each change waits for a deployment, and the evaluation slows all the way down to that tempo.
Amazon Bedrock AgentCore is a platform to construct, join, and optimize brokers at scale, together with your alternative of agent framework and basis mannequin (FM). AgentCore runtime, a functionality of Amazon Bedrock AgentCore, runs every agent session in its personal remoted microVM. With Session endpoints, you possibly can open an app working in that session from your individual browser. Session Endpoints give every session an authenticated URL that forwards every request’s HTTP methodology, path, question string, and physique, and WebSocket connections, to the ports you permit. You may watch the web page replace because the agent saves every file.
On this put up, you deploy a coding agent that retains a Vite web site working in its session, then open one native web page with a chat on the left and the dwell web site on the precise. You ask the agent to change the positioning to a darkish shade theme, observe its steps as they stream in, and watch the web site change with no refresh. Lastly, you take a look at what occurs internally: a second port in the identical session, and the requests the Session endpoint refuses.
The whole pattern, together with the pocket book this put up follows, is within the 14-remote-access folder of the agentcore-samples GitHub repo.
How Session endpoints work
Every session will get its personal Session endpoint, and 6 particulars form how you utilize it.
You select which ports it reaches. You set allowedPorts while you name CreateAgentRuntime: 1–5 entries, every a single port or a spread inside 8000–12000, excluding the reserved platform ports. Permitting a port doesn’t begin a server, so your utility should pay attention on it, certain to 0.0.0.0.
The URL arrives with the session. The InvokeAgentRuntime response carries it within the X-Amzn-Bedrock-AgentCore-Runtime-Session-Endpoint-Url header, which SDKs that mannequin it expose as sessionEndpointUrl.
Each request is authenticated. For a runtime that makes use of AWS Identification and Entry Administration (IAM), every HTTP request, HTTP/2 stream, and WebSocket handshake carries a Signature Model 4 (SigV4) signature. The caller additionally wants bedrock-agentcore:InvokeAgentRuntimeProxy on the runtime and its runtime endpoint. For a runtime with an inbound JSON Net Token (JWT) authorizer, every request carries a bearer token as an alternative. Understanding the URL doesn’t grant entry.
The host title selects the port. Your shopper connects on port 443 whatever the goal port, and a prefix on the host title chooses the port contained in the session:
It carries the protocols your server speaks. HTTP/1.1 and HTTP/2 requests, together with server-sent occasions and gRPC, and WebSocket connections all go via. This walkthrough makes use of HTTP/1.1 and WebSocket.
It’s scoped to 1 session. The URL wants credentials on each request and lasts solely so long as the session, so use it to construct, take a look at, and evaluation what your agent produces. To serve an app to your customers, deploy it to a internet hosting service akin to AWS Amplify Internet hosting.
A browser can’t add a SigV4 signature or a bearer token to the requests a web page makes by itself, so the Session endpoint shopper within the bedrock-agentcore SDK can open a neighborhood endpoint in your machine. Your browser opens http://localhost:8088, and the native endpoint provides your credentials to every request and WebSocket handshake earlier than forwarding it.
A Session endpoint is completely different from a runtime endpoint, which AgentCore runtime already gives. Use a runtime endpoint, akin to DEFAULT, to succeed in your agent, which controls which model of it callers will attain. InvokeAgentRuntime calls resolve via it, so you possibly can hold improvement and manufacturing on completely different variations and promote or roll again with out altering callers. Use a Session endpoint to see what your agent runs in its session, akin to an internet preview. It’s an authenticated URL that reaches solely the ports you permit, works with whichever model the session runs, and stops working when the session ends. For full documentation, confer with Connect with runtime periods via a session endpoint.
Resolution overview
The pattern has 4 components. A coding agent runs within the session on port 8080 and edits the web site’s information with 4 instruments: checklist, learn, write, and edit. The agent begins a Vite improvement server on port 8090, which serves the web site and pushes every saved change to the browser over its hot-reload WebSocket. In your machine, PreviewApp serves the preview web page, sends your prompts to InvokeAgentRuntime, and opens a neighborhood endpoint for the web site. As Determine 1 reveals, the preview web page masses the web site from the Vite improvement server on port 8090 via the native endpoint and the Session endpoint, and sends your prompts via InvokeAgentRuntime to the agent on port 8080. The numbers present the order of the steps for one request.
Earlier than step 1, PreviewApp has already referred to as InvokeAgentRuntime as soon as to start out the session, which begins the agent and the Vite improvement server. PreviewApp learn the Session endpoint URL from that response and opened a neighborhood endpoint for port 8090. The numbered steps in Determine 1 then observe one request for a change:
- The positioning pane of the preview web page masses the web site from the native endpoint on
localhost:8088. The native endpoint provides your credentials to every request and the WebSocket handshake, and forwards them to the Session endpoint. The Session endpoint checks the signature and the port towardsallowedPorts, then forwards them to the Vite improvement server on port 8090. The web page retains the Vite hot-reload WebSocket open. - You ship a immediate from the chat pane.
PreviewAppsends it toInvokeAgentRuntimeas an ordinary AWS API name signed together with your AWS credentials, and the runtime delivers it to the agent on port 8080. The agent’s steps stream again to the chat pane as it really works. - The agent calls Claude Haiku 5.5 in Amazon Bedrock to resolve what to vary.
- The agent reads the positioning’s information and saves those it adjustments. The Vite improvement server serves these information and watches them for adjustments.
- When a file is saved, Vite pushes the change over the WebSocket opened in step 1, again via the Session endpoint and the native endpoint, and the positioning pane updates with no refresh.
- From the pocket book,
PreviewAppreads the agent’s/standingroute on port 8081 via the identical Session endpoint. Solely the port adjustments.
Port 8080 isn’t in allowedPorts, as a result of InvokeAgentRuntime reaches the agent with out going via the Session endpoint.
Conditions
To observe the walkthrough, you want:
- An AWS account in an AWS Area the place AgentCore runtime Session endpoints can be found, with credentials configured.
- Permissions to create an AWS Identification and Entry Administration (IAM) position, add to Amazon Easy Storage Service (Amazon S3), and create a runtime, plus
bedrock-agentcore:InvokeAgentRuntimeandbedrock-agentcore:InvokeAgentRuntimeProxyon that runtime and itsDEFAULTruntime endpoint. For particulars, confer with IAM permissions for AgentCore runtime. - Python 3.10 or later, with
bedrock-agentcore1.25.2 or later andboto31.43.122 or later. - Git, to clone the pattern repo, and a Jupyter surroundings, akin to JupyterLab or Visible Studio Code with the Jupyter extension, to run the pocket book.
- Entry to Claude Haiku 5.5 in Amazon Bedrock. For mannequin availability by Area, confer with Regional availability by fashions.
- Node.js 22 or later with
npm, which the deployment script makes use of to bundle the agent and the web site.
The pattern deploys the agent as a zipper file in Amazon S3 with direct code deployment for Node.js, so that you don’t want Docker or an Amazon Elastic Container Registry (Amazon ECR) repository. Session endpoints work with microVM runtimes, not with the Situations compute sort, and Session endpoint URLs are reachable over public HTTPS. AWS PrivateLink isn’t supported for inbound connections.
Deploy the agent and its web site
First, you deploy the runtime, and the configuration you select right here decides which ports the Session endpoint can attain. The deployment script bundles the agent into one file, provides the web site and its dependencies for the runtime’s Linux on Arm64 system, uploads the zip to Amazon S3, and creates the runtime.
The next excerpt from deploy.py reveals the 2 settings that matter for this put up. protocolConfiguration says the place the agent listens for InvokeAgentRuntime, and allowedPorts lists the ports the Session endpoint can attain: 8090 for the web site and 8081 for the agent’s standing route. Port 8080 isn’t within the checklist, as a result of InvokeAgentRuntime reaches the agent with out it. For the port and path settings, confer with Configure your agent’s serving port and invocation path.
The web site’s Vite configuration makes the event server reachable from the Session endpoint. It listens on 0.0.0.0 at port 8090 and doesn’t limit the Host header (server.allowedHosts is true), as a result of requests arrive beneath a bunch title the runtime assigns relatively than localhost. The Session endpoint authenticates each request earlier than it reaches the server, so the server doesn’t want its personal host verify.
To deploy the runtime:
1. Clone the pattern repo and alter to the pattern folder:
2. Open session_endpoints_preview.ipynb from the pattern folder.
3. Run the set up cell, which installs the Python dependencies.
4. Run the %run deploy.py cell. Deployment takes a couple of minutes, largely ready for the runtime to succeed in the READY standing.
Open the preview
With the runtime prepared, you begin the preview. One name does three issues: it begins a session (which begins the web site), opens a neighborhood endpoint for port 8090, and serves the preview web page on localhost:8087.
Inside begin(), the calls that use Session endpoints are quick. The primary InvokeAgentRuntime name returns the URL in a response header, session_endpoint_url reads it, and the Session endpoint shopper opens a neighborhood endpoint for port 8090:
To open the preview:
- Run the cell that begins
PreviewApp. - Open the printed hyperlink,
http://localhost:8087, in your browser.
The web page reveals the web site on the precise, served from port 8090 within the session, and a brief information with urged requests on the left.
Ask the agent for a change
Now you ask for a change and watch it arrive. Every immediate goes to the agent via InvokeAgentRuntime. The agent reads the information it wants, writes those it adjustments, and stories every step because it occurs. When a file is saved, the Vite improvement server pushes the change over its WebSocket, via the Session endpoint and the native endpoint, and the web site updates in place.
To ask for a change:
- On the preview web page, select Swap this web site to a darkish coffee-house shade theme.
- Comply with the agent’s steps within the chat pane because it reads and saves information.
- Watch the positioning pane. It adjustments when the agent saves the stylesheet, and a banner names the file the change got here from.
The next video reveals the preview web page whereas the agent works via a number of requests. Selecting a urged request sends it to the agent, the chat pane lists every file the agent reads and saves, and the positioning pane on the precise updates with no refresh, from the darkish theme to a inexperienced Order forward button.
The steps stream as a result of the agent solutions with server-sent occasions while you ask it to. You may ship the identical prompts from Python with app.ask, which reads the stream with iter_events from the bedrock-agentcore SDK. The open web page updates in the identical method:
The output of this Python script ought to resemble the next:
Attain a second port in the identical session
The web site isn’t the one server you possibly can attain. The agent serves /standing on port 8081, which lists every immediate and the information it modified. The identical Session endpoint reaches it, and the one distinction is the port argument.
The output of this Python script ought to resemble the next:
What the Session endpoint refuses
When the runtime refuses a request, it solutions with an HTTP standing, an empty physique, and an error code in a response header, so you possibly can inform its refusals from errors your utility returns. The pocket book sends a request to a port outdoors allowedPorts and a request with out credentials, and the runtime refuses each with 403 AccessDenied.
The next desk lists the refusals you’re prone to meet when you construct with Session endpoints.
| Request | Response from the runtime |
A port that isn’t in allowedPorts |
403 AccessDenied |
| A request with out legitimate credentials | 403 AccessDenied or 401 AuthenticationRequired |
| An allowed port with nothing listening on it | 502 PortNotReachable |
| A URL whose session now not exists | 404 SessionNotFound |
How entry to your session is protected
The runtime removes its personal authentication headers earlier than it forwards a request, so the web site doesn’t obtain your signature. Requests are recorded in AWS CloudTrail as InvokeAgentRuntimeProxy occasions, with the occasion supply bedrock-agentcore.amazonaws.com. The native endpoint acts together with your credentials, so it limits who can use it. It listens on 127.0.0.1 solely, solutions solely requests addressed to its personal native deal with, and refuses WebSocket connections opened by pages from different origins. Run the native endpoint solely when you use the preview. For extra info, see Log session endpoint requests in CloudTrail.
The entry controls don’t separate the web site from the agent. Each run in the identical session, so give the execution position solely the permissions the agent wants. If the runtime replaces the session’s compute, open connections shut, and the agent’s edits won’t survive except the session makes use of persistent storage. Consult with File system configurations for AgentCore runtime if you happen to want the information to outlast the compute.
The agent’s file instruments resolve each path inside the positioning folder and refuse paths outdoors it, so a immediate can’t make the agent change different information within the session. If different individuals can ship prompts to your coding agent, contemplate Amazon Bedrock Guardrails to filter dangerous prompts and responses, and evaluation the agent’s adjustments earlier than you publish them.
Clear up
To keep away from ongoing prices, cease the preview and delete the assets the pattern created. The web site the agent edited lives within the session, so it goes with the session.
To scrub up:
1. Run the cease cell, and press Enter when the pocket book asks. This stops the preview web page, the native endpoint, and the session.
2. Run the %run cleanup.py cell, which deletes the runtime, the uploaded code, and the IAM position.
Conclusion
Session endpoints offer you authenticated entry to the functions in an AgentCore runtime session from your individual instruments over HTTP/1.1, HTTP/2, and WebSocket, on the ports you permit. On this put up, you deployed a coding agent with a Vite web site in its session, opened the dwell web site in your browser via a neighborhood endpoint, requested the agent for a darkish theme, and watched the change arrive because the agent saved the file. You additionally reached a second port in the identical session and confirmed what the Session endpoint refuses.
To go additional, run the pocket book with your individual web site within the web site folder, or change the agent’s instruments to match how your coding agent works. For the complete set of choices, together with port ranges, OAuth, HTTP/2, and gRPC, confer with Connect with runtime periods via a session endpoint.
To vary the port or path that InvokeAgentRuntime makes use of in your individual agent, confer with Configure your agent’s serving port and invocation path. In case your agent additionally must run construct or take a look at instructions in the identical session, confer with Execute shell instructions in AgentCore runtime periods. To deploy your individual Node.js agent from a zipper file the best way this pattern does, confer with Direct code deployment for Node.js. For every part else the service provides, begin with Host agent or instruments with Amazon Bedrock AgentCore runtime, and discover extra examples within the agentcore-samples GitHub repo.
Concerning the writer


