Get startedGet started for free

Deploying Agents to the Cloud

1. Deploying Agents to the Cloud

So far, everything we've built has been running on my local machine. Now, we're going to deploy it to the cloud. You can package a Strand's agent into a container and run it anywhere, but in this video, we'll deploy it to AWS using Amazon Bedrock Agent Core. Agent Core is a collection of components for building, deploying, and operating AI agents in production. It includes things like runtime, memory, gateway, observability, identity, evaluations, and more. You can use them together or independently. The main pieces we'll focus on today are Agent Core runtime and Agent Core memory. Agent Core runtime is the hosting environment for your agent code. It runs agents inside isolated micro VMs, so long-running and multi-agent workflows can maintain isolated state across requests. We'll also use Agent Core memory for persistent conversation storage and long-term memory retrieval. And we'll automatically get observability and tracing through Agent Core observability without having to manually wire anything up ourselves. Let's deploy the same customer service agent we've been building throughout the course. Most of the agent code itself stays the same, but we do need to add a few things to make it deployable. At the top, I create an import where I import Bedrock Agent Core app, and then I create a Bedrock Agent Core app instance. Then, scrolling down, I need to go to the entry point and add this app.entrypoint decorator to define the function that handles incoming requests. That function receives a payload dictionary, extracts the prompt and session information, runs the agent, and returns a response dictionary. At the bottom, I also had to add this app.run, so that it actually starts the server. I also added the Agent Core memory integration. If I scroll up to the function where we actually create the agent, we are first creating the AgentCore memory config and then the AgentCore memory session manager. The AgentCore memory session manager connects the agent to a managed memory resource deployed in AWS. It uses an actor ID to identify the user and a session ID to identify the specific conversation. That gives us persistent conversation history and long-term memory retrieval across sessions. For example, if a customer had an account issue several conversations ago, the agent can recall that information later without being told again. The integration pattern is intentionally very similar to what we already used earlier in the course with session managers. We just swap out the session manager implementation whenever we create the agent. If I scroll back up, I also configured retrieval settings for the long-term memory recall. This allows for the session manager to automatically retrieve relevant long-term memories and inject them back into context during agent execution. Then, back down in the invoke function, I added logic to pull out the prompt, actor ID, and session ID from the incoming request payload. And finally, I added the deployment dependencies including Strands, AgentCore, and OpenTelemetry instrumentation for tracing. Now, let's actually deploy it. First, though, you need to install the AgentCore command line interface. Then, you want to create a new project. To do that, I'll run AgentCore create. This is going to go through a number of different prompts that will create the project structure, dependencies, configuration, and infrastructure files automatically. For the project name, I'll call this customer service agent. And then, we want to say yes, I want to add an agent now. We'll leave the agent name as my agent, and then I want to bring my own code for the agent. I will accept the defaults for bringing my own code, which tells it where to find the local files. And then I'll hit enter. Next we have to select the build type. We're going to use direct code deploy here. This is just how AgentCore bundles up your code and runs your agent. And then we will select Bedrock as our model provider. Then there's some customized advanced settings. We don't need any of these, so we'll skip through them. And then finally, we will hit enter, which will then create the local files that are necessary to launch our agent to AgentCore whenever we deploy. AgentCore create is done running, and it's created this folder for me here locally that has an app directory where I can then drop our customer service agent code into this generated project structure. Next we'll add memory support by running AgentCore add memory, providing our agent memory with a name of customer service memory, and then also providing long-term strategies for memory extraction, like semantic and user preference, and then I will hit enter. That added memory. And now what we need to do is actually deploy this. To do that, I'll run AgentCore deploy and hit enter. And this first deployment will take a couple of minutes while AWS provisions the necessary infrastructure. The agent is now deployed to AgentCore runtime, and I have this helper file here that has some commands I'm going to run to interact with the deployed agent. I've set an environment variable to set the session ID. And then to invoke the agent, I'll run a command called AgentCore invoke, passing in the session ID, and then the that says I need help returning my order, as well as an actor ID, which is simulating my username. Paste that in, and now we are invoking the agent that's hosted in Agent Core runtime. We can see the response came back that says, "I'd be happy to help you with the return. Can you please provide me with your customer ID?" So, now I'm going to pass in another Agent Core invoke command referencing that same session ID. So, we should be routed back to the same live session running on Agent Core. And this time I'm just passing in as the prompt the ID. So, if memory is working correctly, it should be able to carry that context from the first turn to the second within the same session, bringing that information back into memory. Okay, we can see that it's come back that they were able to The agent was able to find my account. And so, now it's asking which order to return, the headphones or the USB. I'm going to paste in the next command, which says headphones. And again, this is pulling those memories from short-term memory that's powered by Agent Core memory. Now, the agent's come back and is asking me to confirm if I want to return that, and I will just say, "Yes." All right, and our refund has been processed. So, this is showing a working agent where we have the agent deployed on runtime, and it's also using Agent Core memory for conversation history. Now, one other thing I want to show you is observability. Agent Core observability is provided automatically whenever you bring in the OTel dependency and automatically instruments your code. So, let's take a look at some traces for this. Here we are in the Agent Core console, and I'm looking at the customer service agent that we just deployed. And you can see here we have these endpoints, and if I scroll over, it shows you the logs and the dashboard. I'm going to go ahead and select dashboard. Here we are in the GenAI observability dashboard. And if I select all sessions, this will bring up the session that we just got done interacting with the agent. So, I'll select the session ID, which brings up the traces. And then from here, I can select a trace. I'll do this one here. Which then brings up this sort of visual trajectory. I can make this a little bit larger. You can see we had a invoke the agent. We are executing the loop, and then it also invokes chat. But, if I come over here on the right-hand side, you can see the messages come through. So, here we have the content. You can see that we have the system prompt here. And if I scroll down, you can also see that injected available skills. Uh the skills plugin injects this into the context just for the system prompt. And then you can see all of the skills that exist. And if we keep scrolling down, we can then see the content coming from the user, where I said wireless headphones is the one I wanted to return. And if we scroll down, we can see the output as well. This is what was returned from the agent. If I also then scroll up, I can select timeline. And this shows you all of the different spans for this particular session. And you can then drill down and see the metrics for each span, as well. Agent Core also includes additional components like gateway for exposing APIs as MCP compatible tools that you could use with your Strands agents. We won't cover that deeply here, but they become useful as systems grow more complex. One important thing to remember is that a deployed agent itself is only part of the overall production architecture. Agent Core runtime handles the authentication gate automatically using either IAM or OAuth. But, in a real system, you still need surrounding infrastructure like API gateways, rate limiting, retries, security controls, monitoring, and error handling. Throughout this course, we built up the orchestration layer for your harness for things like context, tools, hooks, steering, multi-agent coordination, and evaluations. In this video, we added the infrastructure layer underneath it. Together, that's your harness. Now, you can compose these systems for your own use cases. There's also a lot more in strands that we didn't cover in this course, including agent-to-agent, structured outputs, bidirectional streaming, and additional orchestration patterns. All the code from every video is included in the companion GitHub repository. Thanks for watching.

2. Final slide

Congratulations — you can now design, build, evaluate, and deploy AI agent harnesses with Strands.

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.