Introduction
AI applications are moving beyond simple question-and-answer interfaces.
A traditional chatbot receives a prompt and generates a response. An agentic AI application can take a request, determine what information it needs, select a tool, execute an action, observe the result and use that result to complete the task.
This is the approach I explored while building Primetress AI, an internal inventory and procurement assistant designed to help employees find IT equipment, check inventory information and initiate procurement workflows.
The application uses Amazon Bedrock AgentCore Runtime to host the agent, Strands Agents to implement its reasoning and tool-calling logic, and AWS services to provide the backend capabilities.
In this tutorial, we will build a simplified version of that architecture.
By the end, you will have:
- Created a Python agent using Strands Agents.
- Defined a system prompt that guides the agent's behavior.
- Created a custom tool the agent can call.
- Tested the agent locally.
- Deployed the agent to Amazon Bedrock AgentCore Runtime.
- Invoked the deployed agent and inspected its logs.
The tutorial uses a small inventory assistant as the example. The inventory tool will initially use sample data so that you can understand the agent's behavior without needing to create a database first. We will also discuss how the same tool pattern connects to AWS Lambda and DynamoDB in a real application.
1. Understanding the architecture
Before writing code, it is useful to understand the role of each component.
An agentic application generally consists of four important parts:
- A foundation model that interprets requests and decides what to do.
- Instructions that define the agent's role, behavior and constraints.
- Tools that allow the agent to interact with external systems.
- An execution environment that receives requests and runs the agent.
For this project, I used Strands Agents for the agent implementation and Amazon Bedrock for the foundation model.
Amazon Bedrock AgentCore Runtime provides the managed environment in which the agent executes.
The architecture for our tutorial looks like this:
flowchart TD A[User] --> B[AgentCore Runtime] B --> C[Strands Agent] C --> D[Claude on Amazon Bedrock] C --> E[Inventory Tool] E --> F[Inventory Data] D --> C C --> B B --> A The user sends a request to the runtime.
The runtime passes the request to the agent.
The agent uses the foundation model to interpret the request and determine whether a tool is needed.
If a tool is required, Strands executes the tool and provides its result to the model.
The model then generates a response based on the tool result.
This is the basic agentic loop.
What is Amazon Bedrock AgentCore?
Amazon Bedrock AgentCore is a set of capabilities for building, deploying and operating AI agents.
AgentCore Runtime is the hosting component used in this tutorial.
It provides an execution environment for agents built with frameworks such as Strands Agents, LangGraph and other supported implementations.
The important distinction is that AgentCore Runtime does not define the agent's business logic for us. We still write the instructions, tools and application code.
AgentCore provides the infrastructure in which that code runs.
For this tutorial, we will use a code-based agent, which gives us control over the agent's orchestration logic. AWS also provides a managed harness approach for developers who prefer to define an agent through configuration rather than writing the orchestration code themselves.
Official documentation: Amazon Bedrock AgentCore
2. Prerequisites
Before getting started, make sure you have the following:
| Requirement | Purpose |
|---|---|
| AWS account | Deploying the agent |
| AWS CLI | Configuring AWS credentials |
| Node.js and npm | Installing the AgentCore CLI |
| Python 3.10+ | Writing the agent |
uv | Python project and dependency management |
| Amazon Bedrock model access | Invoking the foundation model |
The current AgentCore CLI is distributed through npm.
Install it with:
npm install -g @aws/agentcore Verify the installation:
agentcore --version You should also verify that your AWS credentials are configured correctly:
aws sts get-caller-identity This command should return information about the AWS identity currently being used.
If you work with multiple AWS accounts, make sure you are deploying to the intended account and Region.
For this tutorial, I will use us-east-1, the Region used for the Primetress AI project.
The deployment identity needs permissions to create and deploy AgentCore resources, use the required AWS infrastructure services and invoke the selected Bedrock model. The exact permissions depend on the deployment configuration.
The AgentCore CLI uses AWS CDK under the hood to provision infrastructure, so the account may also require CDK bootstrap resources.
AWS prerequisites and deployment permissions are documented in the AgentCore CLI getting-started guide.
3. Creating the agent project
The AgentCore CLI provides a project template for creating a Python agent using Strands Agents.
Run:
agentcore create \ --name PrimetressAgent \ --template agent-python-strands This creates a project with the required application structure and dependencies.
The generated project contains the agent code, project configuration and deployment resources.
A typical structure looks like this:
PrimetressAgent/ ├── agentcore/ │ ├── agentcore.json │ ├── aws-targets.json │ └── cdk/ └── app/ └── agent/ ├── main.py ├── pyproject.toml ├── model/ └── memory/ The exact generated files may vary with the CLI version and template configuration.
The important files are:
main.py
This contains the agent implementation and runtime entry point.
pyproject.toml
This defines the Python dependencies for the application.
agentcore.json
This describes the AgentCore resources associated with the project.
aws-targets.json
This contains the deployment target information, including the AWS account and Region.
The CLI scaffolds much of the deployment configuration for us, allowing us to focus on the agent's behavior.
The current CLI workflow is documented in the AgentCore Runtime quickstart.
4. Understanding Strands Agents
Strands Agents is an open-source SDK for building AI agents.
It provides a straightforward way to define an agent, configure a model, provide instructions and expose Python functions as tools.
A basic Strands agent can be created with:
from strands import Agent agent = Agent() response = agent("Hello, what can you do?") print(response) The SDK handles the interaction between the model and the tools provided to the agent.
When a model requests a tool call, Strands executes the corresponding function and sends the result back to the model.
This allows us to focus on defining the agent's capabilities instead of manually implementing every step of the reasoning loop.
5. Defining the agent's instructions
The system prompt is one of the most important parts of an agentic application.
It establishes the agent's role, responsibilities and behavioral constraints.
For the inventory assistant, the instructions should make it clear that the agent is helping employees find equipment and understand inventory information.
We also need to tell it not to invent stock quantities or claim that an action has been completed when it has not.
A system prompt for the tutorial could look like this:
SYSTEM_PROMPT = """ You are an internal IT inventory assistant. Your responsibilities are to help employees: - Find IT equipment. - Check product specifications. - Understand inventory availability. - Identify suitable products for their requirements. When answering questions about current inventory, use the inventory tool whenever appropriate. Never invent stock quantities or product availability. If the inventory tool does not return the information needed to answer a question, explain that the information is unavailable. Do not claim that a purchase request has been submitted unless an authorized procurement tool has confirmed it. """ The system prompt is not a replacement for application-level security.
It guides the model's behavior, but it does not enforce permissions or guarantee that the model will always follow the instructions.
For example, if the application allows employees to submit procurement requests, the backend must still validate the request before creating a record.
The model should not be trusted to enforce business rules on its own.
6. Creating a custom tool
An agent needs tools to interact with information outside the language model.
In Strands, we can expose a Python function as a tool using the @tool decorator.
For this tutorial, we will create a simple inventory lookup tool.
The tool will use sample inventory data so that the example can be tested without creating a DynamoDB table.
Add the following code to the agent's main.py file:
from strands import Agent, tool INVENTORY = { "LAPTOP-001": { "name": "Lenovo ThinkPad", "ram": "16GB", "storage": "512GB SSD", "quantity": 5, }, "LAPTOP-002": { "name": "Dell Latitude", "ram": "8GB", "storage": "256GB SSD", "quantity": 3, }, "DESKTOP-001": { "name": "HP Workstation", "ram": "32GB", "storage": "1TB SSD", "quantity": 2, }, } @tool def lookup_inventory(sku: str) -> dict: """ Look up an IT product by its SKU. Use this tool when an employee asks about a specific product or its stock quantity. Args: sku: The product SKU to search for. Returns: Product information or a not-found message. """ product = INVENTORY.get(sku.upper()) if product is None: return { "found": False, "message": f"No product found for SKU {sku}", } return { "found": True, "sku": sku.upper(), **product, } Let's understand what is happening here.
The INVENTORY dictionary represents a simplified inventory data source.
The lookup_inventory function accepts a SKU and returns the corresponding product information.
The @tool decorator exposes the function to the Strands agent.
The function's name, type hints and docstring help the model understand what the tool does and how to use it.
When an employee asks about a product, the model can decide to call this tool.
For example:
"How many Lenovo ThinkPads do we have in stock?"
The model may identify LAPTOP-001 as the relevant SKU and request a tool call.
The tool returns the quantity, and the model uses that result to answer the employee.
The sample data is intentionally simple. In a real inventory application, the tool would query a database or call a backend service.
7. Connecting the tool to the agent
Now that we have created the tool, we need to make it available to the agent.
Add the following code:
agent = Agent( tools=[lookup_inventory], system_prompt=SYSTEM_PROMPT, ) The tools argument tells Strands which functions the agent can use.
The system_prompt argument provides the instructions that guide its behavior.
When the agent receives a request, the model can decide whether to answer directly or call the inventory tool.
For example:
response = agent( "How many Lenovo ThinkPads do we have in stock?" ) print(response) The agent can call lookup_inventory and use the returned quantity to generate its response.
This is an important distinction from a normal chatbot.
The model is not expected to memorize the inventory data. It retrieves the information through a tool at runtime.
8. Configuring the foundation model
For the Primetress AI project, I used Claude on Amazon Bedrock.
The model configuration can be made explicit using the Strands BedrockModel class.
from strands.models import BedrockModel model = BedrockModel( model_id="us.anthropic.claude-sonnet-4-6", region_name="us-east-1", ) The model ID above is the inference profile used in the Primetress project.
The model must be available to your AWS account and supported in the selected Region.
You can then pass the model to the agent:
agent = Agent( model=model, tools=[lookup_inventory], system_prompt=SYSTEM_PROMPT, ) Explicit model configuration is useful because it makes the model choice visible and easier to change.
It also avoids relying on a framework's default model configuration.
9. Integrating the agent with AgentCore Runtime
The agent now has a model, instructions and a tool.
The next step is to expose it through the AgentCore Runtime interface.
The AgentCore SDK provides BedrockAgentCoreApp, which can be used to define the runtime entry point.
The entry point receives the invocation payload and passes the user's prompt to the agent.
The following is a simplified runtime implementation:
from bedrock_agentcore.runtime import BedrockAgentCoreApp from strands import Agent, tool from strands.models import BedrockModel app = BedrockAgentCoreApp() SYSTEM_PROMPT = """ You are an internal IT inventory assistant. Help employees find products and check inventory. Use the inventory tool for current stock information. Never invent product quantities. """ INVENTORY = { "LAPTOP-001": { "name": "Lenovo ThinkPad", "ram": "16GB", "storage": "512GB SSD", "quantity": 5, }, "LAPTOP-002": { "name": "Dell Latitude", "ram": "8GB", "storage": "256GB SSD", "quantity": 3, }, } @tool def lookup_inventory(sku: str) -> dict: """Look up a product by SKU and return its inventory details.""" product = INVENTORY.get(sku.upper()) if product is None: return { "found": False, "message": "Product not found", } return { "found": True, "sku": sku.upper(), **product, } model = BedrockModel( model_id="us.anthropic.claude-sonnet-4-6", region_name="us-east-1", ) agent = Agent( model=model, tools=[lookup_inventory], system_prompt=SYSTEM_PROMPT, ) @app.entrypoint def invoke(payload): prompt = payload.get("prompt", "") if not prompt: return { "error": "A prompt is required" } response = agent(prompt) return { "response": str(response) } if __name__ == "__main__": app.run() This example brings the agent and runtime integration together.
The BedrockAgentCoreApp object provides the runtime interface.
The @app.entrypoint decorator identifies the function that handles incoming requests.
The function receives a payload containing the user's prompt.
The prompt is passed to the Strands agent, and the agent's response is returned to the runtime.
The runtime then sends the response back to the caller.
The exact entrypoint and project configuration should follow the files generated by the AgentCore CLI template. The code above illustrates the application logic and runtime integration in a compact form.
10. Testing the agent locally
Before deploying to AWS, it is important to test the agent locally.
From the project directory, run:
agentcore dev The CLI starts the local development environment and provides a way to interact with the agent.
You can also use the browser-based Agent Inspector:
agentcore dev --mode browser This is useful for testing prompts and observing how the agent behaves.
Try asking:
"How many Lenovo ThinkPads do we have in stock?"
You should receive a response based on the sample inventory data.
You can also test a product that does not exist:
"Do we have a MacBook Pro with SKU UNKNOWN-001?"
The agent should explain that the product was not found rather than inventing a stock quantity.
Local testing is important because it allows us to validate the agent's instructions and tool behavior before incurring deployment costs.
11. Deploying the agent to Amazon Bedrock AgentCore Runtime
Once the agent works locally, we can deploy it.
The AgentCore CLI provides the deployment workflow.
First, build the project:
agentcore build Then deploy:
agentcore deploy The CLI packages the application, prepares the deployment resources and provisions the AgentCore Runtime endpoint.
The current CodeZip template can deploy without requiring you to build a Docker image locally.
You can check the deployment status with:
agentcore status The first deployment may take longer because the account may need CDK bootstrap resources and other infrastructure to be created.
After deployment, the runtime becomes available for invocation.
12. Invoking the deployed agent
Once the runtime has been deployed, invoke it using the AgentCore CLI.
For example:
agentcore invoke \ --runtime agent \ --payload '{"prompt":"How many Lenovo ThinkPads do we have in stock?"}' The runtime processes the request and returns the agent's response.
The runtime name may differ depending on the project template and configuration. Check the generated project configuration if your runtime is not named agent.
You can also use the interactive CLI workflow to inspect available invocation options:
agentcore invoke --help The AgentCore CLI supports local development, deployment and invocation as part of the same workflow.
This makes it possible to iterate on the agent code, test changes locally and redeploy when the implementation is ready.
13. Connecting the agent to real AWS backend services
The inventory dictionary is useful for learning, but a production inventory assistant needs access to real business data.
In the Primetress AI architecture, the inventory and procurement operations are handled through backend Lambda functions.
The agent's tools can call those functions, which then interact with DynamoDB.
The architecture becomes:
flowchart TD A[Strands Agent] --> B[Inventory Tool] B --> C[Product Actions Lambda] C --> D[DynamoDB Inventory] A --> E[Procurement Tool] E --> F[Procurement Records Lambda] F --> G[DynamoDB Procurement Requests] The important design principle is that the agent does not directly modify the database.
Instead, it calls a tool.
The tool invokes a backend function.
The backend validates the request and performs the operation.
For example, a tool might invoke a Lambda function using the AWS SDK:
import boto3 import json lambda_client = boto3.client("lambda") def invoke_backend( function_name: str, payload: dict, ) -> dict: response = lambda_client.invoke( FunctionName=function_name, InvocationType="RequestResponse", Payload=json.dumps(payload).encode(), ) result = json.loads( response["Payload"].read() ) if response.get("FunctionError"): raise RuntimeError( "Backend Lambda execution failed" ) return result This is a general integration pattern.
The actual payload must match the contract expected by your Lambda handler. For example, the product actions Lambda may expect a specific action name, product identifier or search parameter.
The tool should translate the model's request into that expected payload.
The Lambda function should then validate the input and return a structured result.
This approach allows the agent to use the same backend operations that other parts of the application use.
It also keeps business logic out of the model.
14. Connecting procurement tools safely
A procurement assistant may eventually need to submit purchase requests.
This is a more sensitive operation than checking inventory.
A read-only inventory tool can return information without changing the application's state.
A procurement tool creates a business record and may initiate an approval workflow.
For that reason, a procurement tool should have a clear input schema and should validate the requested quantity, product identifier and business requirements.
The application should also distinguish between:
- Drafting a purchase request.
- Submitting a purchase request.
- Approving a purchase request.
- Actually purchasing equipment.
These are different actions and should not be treated as interchangeable.
For example, the agent may help an employee prepare a request, but the backend should determine whether the employee is authorized to submit it.
The agent should only tell the employee that a request was submitted after the backend confirms that the operation succeeded.
This is one of the most important lessons from building business-focused agentic applications: the model can help determine what action is appropriate, but the application must enforce what actions are allowed.
15. Troubleshooting the deployment
Agentic applications have multiple components, so troubleshooting requires checking the entire request path.
Some common issues include:
AgentCore CLI command conflicts
If the agentcore command does not behave as expected, check whether an older Python-based AgentCore toolkit is installed.
The current CLI is distributed through npm, and an older installation may conflict with it on the system PATH.
Model invocation errors
If the agent cannot invoke the model, verify:
- The model or inference profile ID.
- The AWS Region.
- The AWS identity used by the runtime.
- The required Bedrock permissions.
- Model availability for the account.
Runtime deployment errors
If deployment fails, inspect the CLI output and the generated project configuration.
Check the deployment target, account and Region.
Also verify that the AWS identity has the required AgentCore and CDK deployment permissions.
Tool execution errors
If the model requests a tool but the tool fails, inspect the tool's input and output.
The tool should return useful error information without exposing credentials or sensitive backend data.
Inspecting logs
The AgentCore CLI provides commands for inspecting logs and traces.
For example:
agentcore logs You can also filter recent errors:
agentcore logs \ --since 30m \ --level error The exact options depend on the installed CLI version.
In the Primetress project, runtime logs were particularly useful when the frontend and authentication flow were working but the agent invocation was failing.
This demonstrated why observability should be part of the development process rather than something added after deployment.
16. Security and cost considerations
Before deploying an agent for real employees, consider the following.
Security
The agent's execution role should have only the permissions required to perform its tasks.
The model should not have unrestricted access to AWS resources.
Tools should validate inputs and enforce business rules.
Procurement operations should have appropriate authorization and approval controls.
Sensitive information should not be included in prompts or logs unnecessarily.
Cost
Agentic applications can generate costs from multiple AWS services.
For this tutorial, the main costs are associated with model invocation and the AgentCore Runtime.
A real application may also incur costs from Lambda, DynamoDB, CloudWatch, Knowledge Bases and other supporting services.
For a cost-conscious deployment:
- Start with a small test workload.
- Avoid unnecessary repeated model calls.
- Use the appropriate model for the task.
- Monitor token usage.
- Review AgentCore Runtime usage.
- Clean up test resources when they are no longer needed.
The cost of an agentic application is not just the cost of the foundation model. It is the cost of the complete execution path.
17. What I learned from building Primetress AI
The Primetress AI project reinforced the importance of separating the agent from the business application.
The agent is responsible for interpreting requests and deciding which tools to use.
The backend is responsible for retrieving authoritative data, validating operations and enforcing business rules.
AgentCore Runtime provides the environment in which the agent executes.
Strands Agents provides the framework for implementing the agent's reasoning and tool-calling behavior.
This separation makes the application easier to maintain and extend.
It also allows the agent to evolve without requiring every backend component to be redesigned.
The initial inventory assistant can later be extended with a Knowledge Base for product documentation, additional tools for procurement workflows, and other AgentCore capabilities as the application requirements grow.
Conclusion
Building an agentic AI application with Amazon Bedrock AgentCore and Strands Agents involves more than connecting a foundation model to a prompt.
We created an agent, defined its instructions, exposed a Python function as a tool, tested the tool-calling behavior and deployed the application to AgentCore Runtime.
The same architecture can be extended to interact with real AWS backend services such as Lambda and DynamoDB.
The most important takeaway is that an agent should reason about which action to take, while the application remains responsible for executing that action safely and reliably.
That is the foundation of the Primetress AI inventory and procurement assistant.
In the next article, I will go deeper into connecting an Amazon Bedrock agent to AWS Lambda tools and using those tools to retrieve structured inventory data from DynamoDB.
