Lesson 1 of 6 Agentic AI Workflows

Building Agents with Amazon Bedrock Agents

This lesson explains how an AI agent uses a foundation model to plan steps, call tools and act on results until a goal is reached, and how Amazon Bedrock Agents builds such agents with configuration rather than code.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe the agent loop.
  • Configure a Bedrock agent with instructions, action groups and knowledge bases.
  • Use traces to understand an agent's decisions.

How agents work

An agent runs a loop: the model reads the user's request, its instructions and the available tools, decides on an action (call a tool, query a knowledge base, ask the user or answer), observes the result and repeats. This reasoning and acting pattern lets agents handle multi-step tasks, such as checking an order, applying a refund policy and issuing a credit, that a single prompt cannot. Agents are useful when the sequence of steps is not known in advance; when it is, a deterministic workflow such as Step Functions is simpler and more predictable.

The following diagram shows the agent loop.

The agent loop. The model reads the request, its instructions and the available tools, decides on an action, such as calling a tool, querying a knowledge base, asking the user or answering, observes the result and repeats until it can answer. The model chooses the sequence of steps for each request.
Each pass through the loop is one reasoning and acting step.
Put in order

One agent turn

Exam skills 3.1.6

Arrange what happens when a user asks a returns agent to start a return.

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

Bedrock Agents components

A Bedrock agent is configured with a foundation model, instructions that describe its role and rules, action groups and knowledge bases. An action group defines tools with an OpenAPI schema or function details; when the agent calls a tool, Bedrock invokes a Lambda function with the parameters, or uses return of control to send the parameters back to the application, which runs the action itself, useful for user confirmation or actions in client systems. Agents can also use a code interpreter, user confirmation before actions, memory across sessions, guardrails and prompt templates that can be overridden.

The following diagram shows the knowledge base and action groups of an agent that handles product returns.

The returns agent. A knowledge base holds the returns policy; the orders action group calls get_order through a Lambda function that reads DynamoDB; and the returns action group's create_label uses return of control, so the web application asks the customer to confirm before it calls the label service itself.
The scenario is illustrative.
Match the pairs

Bedrock Agents parts

Exam skills 3.1.6

Match each Bedrock Agents component with its role.

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

Traces and orchestration

Agents make decisions in several steps, so when an agent behaves unexpectedly, the final answer alone does not explain why. Enabling trace on an InvokeAgent request returns the agent's reasoning at each step, the action group and knowledge base calls it made, their inputs and outputs, and any guardrail interventions.

Traces are essential for debugging: they show whether the agent chose the wrong tool, passed wrong parameters, received an error from a tool or misread a result. The following table summarises the components of Bedrock Agents.

ComponentPurpose
InstructionsRole, goals and rules for the agent
Action group (OpenAPI or function schema)Tools the agent can call
Lambda executorRuns the tool logic
Return of controlApplication runs the action, for example after user approval
Knowledge baseRAG over documents
TraceStep-by-step reasoning and tool calls for debugging
Worked example

A returns agent

A retailer wants an assistant that can look up an order, check eligibility under the returns policy and create a return label after the customer confirms.

  • Knowledge base: returns policy documents.
  • Action group orders with a function get_order(order_id) backed by a Lambda function that reads DynamoDB.
  • Action group returns with create_label(order_id) using return of control, so the web application asks the customer to confirm before calling the label service.

The agent decides the order of steps per conversation. Return of control keeps the irreversible action under the application's control, which is safer than letting the agent call the label service directly.

Check yourself

What does return of control do in Bedrock Agents?

Show answer

It returns the action to the application, which runs or confirms it instead of a Lambda function.

Exam Tips

Remember for the exam

  • Unknown sequence of steps with tools: agent; fixed sequence: Step Functions.
  • Bedrock Agents tools: action groups with OpenAPI or function schemas and Lambda.
  • Application must run or confirm the action: return of control.
  • Debug agent reasoning and tool calls: enable trace.
  • Agents can use knowledge bases and guardrails.