Lesson 4 of 5 Generative AI and Machine Learning Architectures

Architecting AI Agents with Amazon Bedrock AgentCore

This lesson explains how agents use models and tools, what each AgentCore service provides, and how to give agents safe access to tools.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe the agent loop and the role of tools.
  • Distinguish Amazon Bedrock Agents from the AgentCore services.
  • Identify the AgentCore service that meets a hosting, tool, memory, identity, policy or observability need.
  • Explain the controls that limit what a manipulated agent could do.

How agents work

An agent runs a loop: the model receives the goal, the conversation and the descriptions of available tools; it either answers or requests a tool call with parameters; the agent code runs the tool and returns the result; and the loop continues. Tools can be APIs, Lambda functions, databases or knowledge bases. Because the model decides which tools to call, the architecture must control what each tool can do, keep state between steps and record every action.

AWS offers two approaches. Amazon Bedrock Agents is fully managed and configured rather than coded: an agent has instructions, action groups (Lambda functions or API schemas) and knowledge bases, and Bedrock runs the loop. Amazon Bedrock AgentCore is a set of services for agents built with any framework (for example Strands Agents, LangGraph or CrewAI) and any model.

The following diagram shows one pass through the agent loop.

How an agent works. The agent sends the goal, the conversation and the tool descriptions to the model. The model either answers or requests a tool call with parameters; the agent code runs the tool and returns the result to the model, and the loop continues until the model gives a final answer.
The model only requests tool calls; the agent code runs them, which is where least privilege and policy checks are enforced.

AgentCore building blocks

The following table summarises the AgentCore services and what each contributes.

ServicePurpose
RuntimeHosts agents in isolated microVM sessions that can run for up to eight hours, with scaling handled by AWS
GatewayTurns APIs, Lambda functions and OpenAPI or Smithy specifications into Model Context Protocol (MCP) tools
MemoryShort-term conversation memory and long-term memory of facts and preferences
IdentityInbound authentication of callers and outbound credentials (OAuth, API keys) for tools
PolicyDeterministic Cedar-based rules evaluated on tool calls through Gateway
ObservabilityOpenTelemetry traces of sessions, model calls and tool invocations in CloudWatch
EvaluationsScores agent quality offline and on live sessions

The services are modular: a team can host an agent elsewhere and still use Gateway and Identity, or use Runtime with its own tool layer. Each Runtime session has its own isolated environment, so one user's context cannot leak to another.

Match the pairs

AgentCore services

Exam skills 1.2.2

Match each agent requirement with the AgentCore service that provides it.

Log in to try this activity Interactive activities are free with an account.

Designing tool access safely

Tools are where an agent changes the world, so they need the same controls as any API client, and more. Each tool runs with least-privilege credentials; AgentCore Policy enforces rules that must hold regardless of what the model decides, such as limits on refund amounts or which customer's records can be changed; human approval gates high-impact actions; and Observability traces show every call and its parameters. Content that an agent reads, such as emails or web pages, can contain injected instructions, so the design assumes the model may be manipulated and limits what a manipulated model could do.

Select all that apply

Safe tool access

Exam skills 1.2.2 · 2.5.2

Identify controls that limit what a manipulated agent could do.

Log in to try this activity Interactive activities are free with an account.
Worked example

An IT support agent

A company wants an agent that answers IT questions from its runbooks, checks ticket status in a SaaS service desk and resets multi-factor devices for the requesting employee only.

The team builds the agent with an open-source framework and hosts it on AgentCore Runtime, with inbound authentication through the corporate identity provider.

Runbooks are a knowledge base tool. The service desk API and the internal reset API are exposed as MCP tools through AgentCore Gateway; AgentCore Identity obtains an OAuth token for the service desk on behalf of the user. An AgentCore Policy rule allows the reset tool only when the target user equals the authenticated caller. Traces in AgentCore Observability let the operations team investigate any unexpected action.

Check yourself

Why should a limit such as 'refunds under 500 dollars' be enforced in AgentCore Policy rather than in the agent's instructions?

Show answer

Instructions influence the model but can be ignored or overridden, for example by prompt injection. AgentCore Policy evaluates every tool call deterministically and blocks calls that break the rule, whatever the model decided.

Exam Tips

Remember for the exam

  • Agent built with an open-source framework needing isolated, long-running sessions: AgentCore Runtime.
  • Expose existing APIs and Lambda functions to agents as MCP tools: AgentCore Gateway.
  • Rules that must hold whatever the model decides: AgentCore Policy on tool calls, not prompt instructions.
  • Configure an agent without writing orchestration code: Amazon Bedrock Agents with action groups.