Ravindra BagaleCourses & study guides मराठी Track your progress

AWS Cloud

What Is Amazon Bedrock Agents? Action Groups and Tools Explained

A chatbot that only answers from a PDF is a librarian. A chatbot that can create a support ticket, check order status, and then answer is an agent. Amazon Bedrock Agents wrap a foundation model with tools (action groups) and optional knowledge bases so the model can take steps — with guardrails.

In this chapter

  • Why agents need tools beyond RAG
  • What Bedrock Agents and action groups are
  • How a request flows through an agent
  • Industries shipping agents carefully
  • Lab, errors, FAQ, interview

1. Everyday example first

An insurance app user says: update my phone and send policy PDF. The agent must call two APIs and maybe fetch a document — not invent a phone number. Action groups map those APIs; guardrails stop the model from promising refunds it cannot give.

2. Why agents?

RAG retrieves text. Business work needs side effects: create ticket, start Step Functions, query DynamoDB. Agents plan steps, call tools, and summarize. Without clear tools and IAM, agents hallucinate actions.

3. What is a Bedrock Agent?

Imagine a support assistant reviewing a sample order status. A knowledge base supplies text such as the return policy. An action group describes operations the agent can request, such as reading an order status by ID. The model receives the user request and can propose a call with the ID it extracted. The tool handler checks the caller and parameters and then gives back a result. The assistant can turn that result into a sentence. The handler still controls which orders the caller is allowed to see.

A Bedrock Agent packages: instructions (system prompt), optional knowledge base, action groups (OpenAPI schemas to Lambda or return of control), and guardrails. The orchestrator decides when to search, call a tool, or answer.

ConceptPlain meaning
Action groupA bundle of API tools the agent may call
Knowledge baseOptional RAG store for facts
GuardrailSafety filters and denied topics
Return of controlYour app runs the tool, not Lambda
An agent using a tool or knowledge sourceUser request: States the intended outcome; Agent reasoning: Proposes a tool call or retrieval; Tool or retrieval: Handler validates and authorises tool calls; Inspect the result: Check evidence and errors; Response: Explain the result and limitsUser requestStates the intended outcomeAgent reasoningProposes a tool call or retrievalTool or retrievalHandler validates and authorises toolcallsInspect the resultCheck evidence and errorsResponseExplain the result and limits
Plan, call, respond

4. How to build (high level)

In return of control, Bedrock can return a proposed invocation to your application. Your application decides whether the tool call is allowed and executes it if appropriate. It sends the tool result back for the agent to continue. In a sample flow, choose one valid order ID and one missing ID. The first can produce a status. The second should ask for a valid ID or return a safe error. Write the route for each before you attach a real handler, so you can see why a convincing answer does not prove an action happened.

  1. Write the user story and list allowed tools only.
  2. Create Lambdas or ROC handlers with least-privilege IAM.
  3. Describe APIs in OpenAPI for the action group.
  4. Attach a knowledge base only if facts must be grounded.
  5. Add guardrails for PII and denied topics.
  6. Test traces: did it call the right tool with the right args?
# Mental model
# Agent
#  - instruction: never invent order ids
#  - action_group: GetOrder (Lambda)
#  - action_group: CreateTicket (Lambda)
#  - guardrail: block refund promises

5. Agent vs Knowledge Base alone

A knowledge base answers from documents. An agent can also change systems through tools. Many products need both: KB for policy text, tools for account actions. Do not call a chatbot an agent unless it can use tools safely.

6. Safety checklist before production

  • AuthN/AuthZ before sensitive tools
  • Human approval for money-moving actions
  • Audit every tool call
  • Rate limit and max turns
  • Red-team prompts weekly

7. Industries

  • E-commerce: order status + returns ticket
  • Banking: FAQ + secure balance tool behind strong auth
  • Healthcare admin: appointment reschedule with audit
  • Internal IT: reset VPN access via approved runbook API

8. Lab: design one action group on paper

Draw the action request and tool reply next to the conversation. For a valid sample, mark the parsed order ID, the permitted operation and the status that comes back. For the denied sample, mark the point where access is checked and show that the handler does no work. The final answer should match the tool output in both cases.

Do this in ap-south-1 (Mumbai) unless your org forbids it. Set a budget alert first.

  1. Pick get order status by order_id.
  2. Write OpenAPI paths and one error response.
  3. List IAM actions the Lambda needs (dynamodb:GetItem only).
  4. Write three user utterances that should call the tool.
  5. Write one utterance that must NOT call the tool.

Cleanup (stop billing)

  1. No AWS cost if paper-only.
  2. If you created a test agent, delete it and its Lambdas.

9. Common errors and fixes

Each row is a real mistake students and juniors hit. Read the fix before you panic.

Error / symptomFix
Agent invents order idsForce tool use; never answer from imagination.
Action group schema vagueTight OpenAPI types and enums.
Lambda role star on DynamoDBScope to table ARN + GetItem.
No guardrail on refundsDeny topic + human handoff.
KB and tools contradictPrefer tool for live data; KB for policy text.
Infinite tool loopsMax iterations; idempotent tools.
PII in traces stored foreverRedact logs; short retention.
Wrong region model idMatch agent region and model access.
ROC timeout too shortAlign app timeout with agent.
Shared agent for all brandsSeparate instructions per brand.

10. Troubleshooting checklist

  1. Model access not enabled in Bedrock console.
  2. Action group Lambda permission missing.
  3. OpenAPI path != Lambda event mapping.
  4. Guardrail blocking legitimate answers — tune.
  5. Trace shows wrong tool — improve instruction examples.
  6. Latency high — cache static FAQ in KB.

11. FAQ

Q. Agent vs plain Bedrock InvokeModel?

InvokeModel = one shot; Agent = plan + tools + memory of steps.

Q. Do I need a knowledge base?

Only for grounded documents; live orders need tools.

Q. Can agents call Step Functions?

Yes via Lambda or API tool.

Q. How to stop hallucination?

Require tools for facts; guardrails; tests.

Q. Is this the same as Agents for Amazon Bedrock in console?

Yes — console/API name for this feature family.

12. Interview Q&A

Q. What is a Bedrock Agent?

FM plus instructions, optional KB, action groups, guardrails.

Q. What is an action group?

OpenAPI-described tools backed by Lambda or ROC.

Q. KB vs tool?

KB = documents; tool = live side effects / queries.

Q. How secure an agent?

Least privilege IAM, guardrails, auth before sensitive tools.

Q. Return of control?

Your application executes the tool call.

Q. Testing strategy?

Utterance suite + trace assertions on tool args.

13. Tips in English, Marathi and Hindi

Ravindra Bagale's Tip (EN)

Design tools first. A clever prompt cannot fix a missing API.

Ravindra Bagale's Tip (MR)

आधी tools डिझाइन. Prompt missing API दुरुस्त करत नाही.

Tip (HI)

पहले tools डिज़ाइन करो — बढ़िया प्रॉम्प्ट missing API नहीं बचाता।

Try at home

  1. Draw agent boxes: User, Agent, Tool, KB, Guardrail.
  2. Write OpenAPI for one GetOrder tool.
  3. List five prompts that must refuse (refunds, secrets).

In short

  1. Agents = model + tools + optional KB + guardrails.
  2. Action groups describe APIs the model may call.
  3. Live data → tools; documents → KB.
  4. Always test traces and least-privilege IAM.

Revision, interview and comparison cards

Revise this lesson in a few minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens this lesson.

Revision card: What are Bedrock Agents?. A chatbot that only chats cannot book, query, or update your systems. Bedrock Agents plan steps, call action groups (APIs/Lambda), and use knowledge bases to answer with your data. Create an agent → attach a foundation model → add action group + optional KB → prepare → alias → InvokeAgent. User says “reschedule my clinic slot”; agent calls your booking Lambda with structured params.
Revision card: What are Bedrock Agents? · Download PNG · Open card page
Revision card: Action groups. Without tools the agent can only talk; with tools it can change real data. An action group exposes APIs (OpenAPI) or function schemas that Lambda implements for the agent. Define parameters carefully; validate in Lambda; return clear errors the model can recover from. get_appointment(date) and cancel_appointment(id) are two functions in one clinic action group.
Revision card: Action groups · Download PNG · Open card page
Revision card: Knowledge bases. The model does not know your PDF policy until you ground it. A knowledge base chunks and embeds your docs (often in OpenSearch Serverless) for retrieval-augmented answers. Sync S3 docs into the KB; test retrieval; cite sources in the agent instructions when needed. “What is our refund window?” pulls the policy chunk instead of guessing.
Revision card: Knowledge bases · Download PNG · Open card page
Revision card: Prepare and aliases. Editing a draft agent live can break callers mid-change. Prepare builds a snapshot; aliases point apps at a version so you can roll forward safely. Develop on DRAFT → prepare → point alias prod to the new version after test. Mobile app keeps calling alias prod while you experiment on DRAFT.
Revision card: Prepare and aliases · Download PNG · Open card page
Revision card: Guardrails and IAM. An agent with broad Lambda rights can leak or mutate data when prompted badly. Use Bedrock Guardrails, least-privilege agent roles, and input/output checks on every action. Scope IAM to specific Lambda ARNs; deny destructive actions unless required; log InvokeAgent. Prompt injection trying “dump all users” fails action auth and is logged for review.
Revision card: Guardrails and IAM · Download PNG · Open card page
Comparison: Bedrock Agent vs Bedrock Converse API. Bedrock Agent: Plans, uses tools/KB, multi-step goals. Bedrock Converse API: Single-turn/multi-turn model chat you orchestrate.
Comparison: Bedrock Agent vs Bedrock Converse API · Download PNG · Open card page
Comparison: Action group vs Knowledge base. Action group: APIs/Lambda the agent can call to change or fetch live data. Knowledge base: Retrieved chunks from your documents (RAG).
Comparison: Action group vs Knowledge base · Download PNG · Open card page
Interview card: What is a Bedrock Agent?. An orchestration layer that plans, uses knowledge bases, and calls action groups to complete user goals. Not only chat — it can act through your APIs. Clinic agent reschedules via Lambda action group.
Interview card: What is a Bedrock Agent? · Download PNG · Open card page
Interview card: What is an action group?. APIs/functions (OpenAPI or schema) implemented by Lambda that the agent can call as tools. Validate inputs; return structured errors. get_slot / book_slot functions for booking.
Interview card: What is an action group? · Download PNG · Open card page
Interview card: Why use an alias?. Aliases point applications at a prepared version so DRAFT edits do not break prod callers. Prepare, test, then move alias. Mobile keeps alias prod while you change DRAFT.
Interview card: Why use an alias? · Download PNG · Open card page
Interview card: How do you debug an agent trace?. Read the trace: model thoughts, action inputs/outputs, KB retrieval — fix schema or IAM from failures. Enable detailed logging in non-prod; never log secrets. Action timed out → raise Lambda timeout or shrink payload.
Interview card: How do you debug an agent trace? · Download PNG · Open card page

More cards: Ravi Sir's Cards.

Practise this chapter

Interview questions and answers

How would you prevent a support agent’s status lookup from returning another user’s order?

Treat the proposed action as a request from the application, then validate the order ID and authorization in the handler. If permission is missing, return a safe error and let the agent explain the result. Test one own order and one denied sample on paper or in a dedicated lab.

Check your understanding

Choose an answer, then compare your reasoning with the explanation.

0 of 3 answered correctly
1. Which component would you use for looking up the current status of a particular order?

Answer and explanation

C. An action group describing an approved lookup tool

A live lookup needs an approved operation. A knowledge base can provide informational text.

2. What is delivered back to the application with return of control?

Answer and explanation

A. A proposed tool invocation and parameter information

The app decides whether and how to execute the operation and returns its observed result.

3. Which test shows an authorization boundary in the proposed order tool?

Answer and explanation

A. A request for an unowned test order is denied without running the protected read

The handler must check access independent of the model’s proposed request.

Practice Tasks

Practice checks run in your browser. They check the answer for this exercise; they do not create resources or connect to your AWS account.

About this scenario

Vidarbha Cotton Mills is a textiles business in Nagpur. Ganesh Wankhede looks after its IT and cloud work. They count money in INR and run their AWS resources in the ap-south-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.

0 / 16

Easy List Bedrock agents

See what exists.

List agents.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Easy List knowledge bases

Optional grounding store.

List knowledge bases.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Easy Min tools for order+ticket

Design tools first.

Minimum distinct tools for get-order and create-ticket (enter 2)?

  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Easy KB optional flag as 0/1

KB not always required.

Is a knowledge base mandatory for every agent? Enter 0 for no.

  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Easy Apply the lesson: scenario 5

A Bedrock agent action group uses RETURN_CONTROL. Which component executes the requested external action: your application or the agent's Lambda executor?

  1. Read the situation and identify what you need to decide.
  2. Work through the relevant concept or calculation.
  3. Enter only the requested term or number.
  4. Check your answer, then read the explanation.

Medium Get agent

Inspect instructions.

Get agent vidarbhacottonagid.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium List action groups

Tools attached to agent.

List action groups for agent vidarbhacottonagid.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium Get tool Lambda

Least privilege tools.

Get function vidarbhacotton-tool.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium Filter tool logs

Trace failures.

Filter log events on /aws/lambda/vidarbhacotton-tool.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium GetItem only

Order tool should not scan all.

Allow dynamodb:GetItem on arn:aws:dynamodb:ap-south-1:108737854657:table/vidarbhacotton-orders.

  1. Start with { "Version": "2012-10-17", "Statement": [ ... ] }.
  2. In each statement write Effect, Action and Resource.
  3. Give only what the task needs (least privilege).
  4. Use double quotes and commas correctly. Click Check answer.

Medium Tiny OpenAPI path JSON

Action groups need schemas.

JSON path /orders/{id} method get.

  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Fill in each property with the value from the task.
  4. Click Check answer. Key order does not matter.

Medium Sane max agent iterations

Stop loops.

A common classroom max iterations value (enter 5)?

  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Hard Get action group

Verify OpenAPI binding.

Get action group vidarbhacottonag for agent vidarbhacottonagid version DRAFT.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Hard Prepare agent

Build draft for test.

Prepare agent vidarbhacottonagid.

  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Hard Tool Lambda invoke by agent role

Agent role needs invoke.

Allow lambda:InvokeFunction on arn:aws:lambda:ap-south-1:108737854657:function:vidarbhacotton-tool.

  1. Start with { "Version": "2012-10-17", "Statement": [ ... ] }.
  2. In each statement write Effect, Action and Resource.
  3. Give only what the task needs (least privilege).
  4. Use double quotes and commas correctly. Click Check answer.

Hard Guardrail topics JSON

Block refund promises.

JSON denied_topics array refunds and secrets.

  1. Start from the top-level keys the task names.
  2. Indent child keys with 2 spaces (no tabs).
  3. Fill in each property with the value from the task.
  4. Click Check answer. Key order does not matter.