Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,9 @@ Dockerfile
01-tutorials/03-AgentCore-identity/07-Outbound_Auth_3LO_ECS_Fargate/backend/runtime/requirements.txt
01-tutorials/03-AgentCore-identity/07-Outbound_Auth_3LO_ECS_Fargate/backend/session_binding/requirements.txt
01-tutorials/03-AgentCore-identity/07-Outbound_Auth_3LO_ECS_Fargate/cdk.context.json

### ASH ###
.ash/

### PowerPoint ###
01-tutorials/10-Agent-Registry/01-advanced/planner-executor-pattern/images/planner-executor-architecture.pptx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# AWS Configuration
AWS_REGION=us-west-2

# Auth0 OAuth Configuration (optional — leave empty to use IAM auth)
# See the Auth0 Setup section in the notebook for instructions.
AUTH0_DOMAIN=
AUTH0_CLIENT_ID=
AUTH0_CLIENT_SECRET=
AUTH0_AUDIENCE=https://bedrock-agentcore.us-west-2.amazonaws.com

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Planner + Executor: Runtime Tool Discovery with AWS Agent Registry

## Overview

When building AI agents that need to discover and use tools at runtime, loading every
available tool into the LLM context upfront is expensive, slow, and wasteful. As your
tool catalog grows — across order management, payments, shipping, notifications, and
more — the token cost and latency of stuffing all tool schemas into every request
becomes a real bottleneck.

This notebook demonstrates the **Planner + Executor pattern**, a two-phase approach to
runtime tool discovery that solves this problem:

1. **Planner Agent** — receives a task, searches the AWS Agent Registry to discover
which tools are relevant, and outputs a minimal Tool Plan. It never executes
business logic — it only identifies what's needed.

2. **Executor Agent** — loads only the tools specified in the Plan, creates live
connections to MCP servers and A2A agents, and executes the task step by step.

This pattern delivers three key benefits:

- **Runtime discovery** — agents find the right tools dynamically from the Registry
instead of hardcoding them, so new tools become available without redeploying agents
- **Token optimization** — the Executor's context contains only the tools it needs
(e.g., 2-3 out of 12), significantly reducing input tokens and cost compared to
loading everything upfront
- **Faster execution** — smaller context means faster LLM inference and fewer
irrelevant tool calls

In this notebook you will be using **real deployed services** — 9 MCP tools on AgentCore Gateway and
3 A2A agents on AgentCore Runtime — to run 3 end-to-end e-commerce scenarios. You will perform runtime discovery of the required MCP servers and A2A agents for each scenario using Planner agent and then use Executor agent to execute the scenario based on the plan and tools provided by the Planner agent. You will also analyze the token and cost savings that comes with runtime tool discovery and execution.

## Deploying MCP tools to Amazon AgentCore Gateway and A2A agents to Amazon AgentCore Runtime

Run these notebooks first to deploy the tools and agents:
1. `00-deploy-sample-mcp-tools.ipynb` — deploys 9 MCP tools on AgentCore Gateway
2. `00-deploy-sample-a2a-agents.ipynb` — deploys 3 A2A agents on AgentCore Runtime

Both notebooks save config files (`utils/mcp_tools_config.json`, `util/sa2a_agents_config.json`)
that this notebook loads automatically.

**These MCP servers and A2A agents will be deployed to Amazon AgentCore once above notebooks are executed**

| Tool | Protocol | Purpose |
|---|---|---|
| `order_lookup_tool` | MCP | Look up order details and list orders by customer |
| `order_update_tool` | MCP | Update order status or shipping address |
| `order_cancel_tool` | MCP | Cancel an order |
| `email_send_tool` | MCP | Send transactional emails to customers |
| `email_template_tool` | MCP | Manage reusable email templates |
| `sms_notify_tool` | MCP | Send SMS notifications |
| `payment_status_tool` | MCP | Look up payment status for an order |
| `inventory_check_tool` | MCP | Check available stock for one or more SKUs |
| `shipping_track_tool` | MCP | Track shipments and get delivery estimates |
| `returns_processing_tool` | MCP (remote) | Process product returns and generate return labels |
| `loyalty_rewards_tool` | MCP (remote) | Manage loyalty points and redeem rewards |
| `payment_refund_tool` | A2A | Issue refunds with multi-step validation |
| `inventory_reserve_tool` | A2A | Reserve inventory with rollback support |
| `shipping_update_tool` | A2A | Create shipments with carrier selection and status updates |

## Architecture

![Planner + Executor architecture](images/planner-executor-architecture.png)

## Tutorial

- [Planner Executor Pattern](planner-executor.ipynb)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading