AWS and Strands: Create Your Educational AI Agent in the Cloud

Le brief IA que les pros lisent chaque soir
Les 7 actus IA du jour, décryptées en 5 min. Gratuit.
Inclus dès l'inscription : notre sélection des meilleurs guides & comparatifs IA.
Choisis ton rythme
Gratuit · Pas de spam · Désabonnement en 1 clic
Building and Deploying an Agent on AWS with Strands and AgentCore
Creating an artificial intelligence agent capable of performing useful tasks can be a relatively straightforward endeavor. For a basic application, just a few lines of Python code using the boto3 library and the Bedrock API are often sufficient. The process involves setting up access to a large language model (LLM), sending a prompt and inputs, and then receiving and returning a response to the user.
However, complexity increases when the application needs to handle more responsibilities. For example, if the model must maintain the context of a conversation, choose between different tools, follow detailed instructions, or coordinate multiple steps, the application code begins to resemble a sophisticated agent framework. This is where Strands and AgentCore come into play.
Strands provides this agent layer, but for the agent to function reliably, a set of additional concerns must be addressed. This includes the need for a runtime environment, an invocation interface, session isolation, scalability, security, and potentially services like long-term memory or managed access to tools. Amazon Bedrock AgentCore offers these operational capabilities without imposing specific behavior on the agent itself.
The Agent We Will Build
We will design and deploy an educational assistant using Strands, to which we will add AgentCore memory to retain user preferences between conversations. This agent will be capable of answering questions in the following areas:
- Physics
- Chemistry
- Mathematics
- History
The model will determine the most appropriate subject for each question, thereby eliminating the need to maintain a list of keywords or a separate routing tool. It will respond to questions in the supported domains as an expert and will decline those that fall outside of these four categories.
This type of agent is a good starting point because its behavior is easy to understand while involving decisions found in more complex systems: model selection, instruction drafting, request validation, model behavior testing, application deployment, and conversation session management.
For this initial implementation, I chose to use a single Strands agent rather than specialized agents for each subject. Separate agents become relevant when topics require different models, tools, instructions, data, or permissions, but for now, that would add unnecessary coordination and complexity.
Capabilities of Amazon Bedrock AgentCore
Amazon Bedrock AgentCore is a set of managed services by AWS for building, deploying, connecting, and operating agents in the AWS cloud. It is framework-agnostic, meaning it can host agents built with Strands, LangChain, OpenAI Agents SDK, and other frameworks. The main capabilities of AgentCore include:
-
Runtime: Hosts and scales agents in session-isolated environments, supporting streaming and HTTP, MCP, and A2A protocols.
-
Memory: Stores conversation events and extracts durable facts, preferences, summaries, or episodes for use across sessions.
-
Gateway: Exposes APIs, Lambda functions, and MCP servers as managed tools that agents can discover and call.
-
Identity: Manages incoming authentication and credentials that agents use to access external services.
-
Policy: Applies Cedar authorization rules to Gateway tool calls before they reach their targets.
-
Browser: Provides managed browser sessions for agents that need to interact with websites.
-
Code Interpreter: Executes Python, JavaScript, or TypeScript in managed isolated environments.
-
Observability: Sends logs, traces, and metrics from agents to services like CloudWatch and X-Ray.
-
Evaluations: Measures agent behavior and response quality using built-in or custom evaluators.
These capabilities are independent, meaning an agent can use only those it needs and add others as its responsibilities grow.
Installing Development Tools
To follow this guide, you will need several tools and configurations:
- AWS credentials configured locally.
- Node.js version 20 or later.
- Python version 3.10 or later.
- AWS CDK (used by AgentCore for deployment).
- AgentCore CLI.
- Access to the selected model in Amazon Bedrock.
My installation was performed on a Windows PC using PowerShell. Start by installing the AWS CLI and Node.js if these commands are not already available.
PS C:\ > msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi
PS C:\ > aws --version
aws-cli/2.22.15 Python/3.12.6 Windows/11 exe/AMD64
Install the AWS CDK globally with npm:
PS C:\ > npm install -g aws-cdk
PS C:\ > cdk --version
2.1126.0 (build a90d578)
Install the AgentCore CLI:
PS C:\ > npm install -g @aws/agentcore
PS C:\ > agentcore --version
The AgentCore CLI collects aggregated anonymous usage analytics to help improve the tool. To opt out: agentcore config telemetry.enabled false. To audit: agentcore config telemetry.audit true. For more information: agentcore telemetry --help.
The create command of the AgentCore CLI creates the Python environment and installs the dependencies of the generated project during local execution. The generated pyproject.toml file records dependencies such as Strands and the AgentCore SDK.
Configure the AWS credentials using the appropriate approach for the environment. For local development, this is typically done using an AWS profile file.
Confirm that the LLM or inference profile you wish to use is available from the intended source region. You can do this from the AWS CLI like this:
PS C:\ > aws bedrock list-foundation-models --region <YOUR_REGION>
PS C:\ > aws bedrock list-inference-profiles --region <YOUR_REGION>
Choosing Your Model
When creating an AgentCore project, the command line flag --model-provider Bedrock selects Amazon Bedrock as the provider but does not specify which base model the application intends to use.
Strands defaults to using one of the Anthropic models when no model is provided. As of this writing, the latest default model for Strands is global.anthropic.[claude](/outil/claude)-sonnet-4–6, but it is advisable to always specify a particular model you want Strands to use.
This example code snippet explicitly specifies the use of Anthropic Claude Sonnet 4.6 via a global inter-regional inference profile:
from strands.models import BedrockModel
model = BedrockModel(
model_id="global.anthropic.claude-sonnet-4-6"
)
Brief IA — L'actualité IA en français
L'essentiel de l'actualité de l'intelligence artificielle, décrypté et expliqué chaque jour.