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

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.

What you'll learn 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?

Why do we need this?

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?

What is it?

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
User → Agent → Tool/KB → AnswerNeed action + text
Plan, call, respond

4. How to build (high level)

How to do it (step by step)

  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

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

How to do it (step by step)

  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.

Practice Tasks

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

Why: See what exists.

What to do: List agents.

How:
  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

Why: Optional grounding store.

What to do: List knowledge bases.

How:
  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

Why: Design tools first.

What to do: Minimum distinct tools for get-order and create-ticket (enter 2)?

How:
  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

Why: KB not always required.

What to do: Is a knowledge base mandatory for every agent? Enter 0 for no.

How:
  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 ROC means app runs tool — enter 1

Why: Return of control.

What to do: Enter 1 if return-of-control means your app runs the tool.

How:
  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.

Medium Get agent

Why: Inspect instructions.

What to do: Get agent vidarbhacottonagid.

How:
  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

Why: Tools attached to agent.

What to do: List action groups for agent vidarbhacottonagid.

How:
  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

Why: Least privilege tools.

What to do: Get function vidarbhacotton-tool.

How:
  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

Why: Trace failures.

What to do: Filter log events on /aws/lambda/vidarbhacotton-tool.

How:
  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

Why: Order tool should not scan all.

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

How:
  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

Why: Action groups need schemas.

What to do: JSON path /orders/{id} method get.

How:
  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

Why: Stop loops.

What to do: A common classroom max iterations value (enter 5)?

How:
  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

Why: Verify OpenAPI binding.

What to do: Get action group vidarbhacottonag for agent vidarbhacottonagid version DRAFT.

How:
  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

Why: Build draft for test.

What to do: Prepare agent vidarbhacottonagid.

How:
  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

Why: Agent role needs invoke.

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

How:
  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

Why: Block refund promises.

What to do: JSON denied_topics array refunds and secrets.

How:
  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.