← Back to Portfolio

🌐 Agent Web Search

AI-Powered Grounded Web Search on Amazon Bedrock AgentCore

⚡Executive Summary

Agent Web Search is a side-by-side comparison tool demonstrating the difference between LLM responses from training data alone vs. real-time grounded responses using AWS-managed Web Search via AgentCore Gateway. Built with Strands Agents on Amazon Bedrock, it features server-side governance with domain and date filters, agentic multi-turn retrieval where the model decides when and what to search, full execution traces, cost transparency ($7/1K searches), and zero third-party search SDK dependencies. The entire search path runs within AWS - no external search engine, no API keys, no third-party egress.

📋Situation

The Grounding Problem

Large language models answer from training data that has a knowledge cutoff. Ask about yesterday's stock price, last week's software release, or today's news, and the model either hedges ("as of my last training data...") or confidently states outdated facts. Enterprises building AI assistants needed a way to ground model responses in current information without introducing third-party search dependencies, managing API keys, or writing custom response-parsing code.

The Integration Challenges

The Core Question: Can a model ground its answers in real-time web data using only AWS-managed infrastructure, with zero third-party search SDKs, full operator governance, and complete transparency into every search decision?

🎯Task

The Challenge: Proving Grounded Search with Zero Third-Party Dependencies

The goal was to build an interactive demo that makes the value of AgentCore Web Search immediately visible - run the same question through the same model twice, once without web search and once with it, and let the side-by-side comparison speak for itself.

The Strategic Imperative: This was not about building a search wrapper. It was about proving a clean integration pattern: one managed connector added to an AgentCore Gateway, discovered by the model via MCP tools/list, governed by server-side policy, and billed transparently - with zero code changes to the agent itself.

⚙️Action

The Architecture

Fully serverless on AWS with a clear trust boundary - the search query crosses into an AWS service account, not out to the internet:

Browser ──► CloudFront ──┬──► S3 (private, OAC)                  static bundle
   (no sign-in)          │
                         └──► API Gateway ──► Lambda ──┬──► Bedrock (model)
                              (Lambda            │     └──► AgentCore Gateway
                               authorizer)       │            └──► web-search connector
                                                 └──► CloudWatch Logs

Trust Boundary:
  Query stays within AWS ──► AgentCore Gateway ──► AWS-managed Web Search
  No third-party egress  ──► No search SDK  ──► No API keys

Two Options - One Model

Option 1: No Web Search Option 2: AgentCore Web Search
Data Source Training data only Training data + real-time web results
Time Sensitivity Cannot answer about events after cutoff Current as of today with publication dates
Citations None - no source attribution Titles, URLs, dates, and snippets per source
Search Cost $0 (no searches) $0.007 per search, only when the model searches
Integration Code Direct Bedrock Converse Same agent + one MCP connector (zero code change)

Technology Stack

Amazon Bedrock Claude Sonnet 4.6 Claude Haiku 4.5 AgentCore Gateway Web Search Connector Strands Agents SDK MCP (Streamable HTTP) SigV4 Auth FastAPI React 19 + TypeScript Cloudscape Design AWS Lambda + Mangum API Gateway CloudFront + S3 (OAC) CloudFormation CloudWatch Logs

Server-Side Governance (SearchPolicy)

A Strands BeforeToolCallEvent hook intercepts every WebSearch invocation before it leaves the agent. The operator's settings are authoritative - whatever the model requests is overridden:

Agentic Multi-Turn Retrieval

MCP Gateway Integration

Execution Tracing

A ToolCallRecorder hook (Strands AfterToolCallEvent) captures every tool invocation with full detail:

Access Control & Security

No viewer authentication by design - anyone with the CloudFront URL can run the demo. Protections are about bounding cost and locking down the path to the agent:

Testing & Quality

Key Design Decisions

Zero Integration Code: The agent calls tools/list and the WebSearch tool is there, schema included. No search SDK, no API key, no response-parsing glue. Adding web search is adding a connector to a Gateway, not writing an integration.

Governance at the Hook Layer: The SearchPolicy hook rewrites tool arguments before they leave the agent. This means governance is architectural, not advisory - the model cannot bypass domain filters or inflate maxResults, and every override is logged.

Model Decides, Operator Controls: The model chooses whether to search and what to search for (agentic behavior). The operator controls how many results, which domains, and what date range (governance). These concerns are cleanly separated.

No Auth for Shareability: Deliberately no viewer authentication so the demo URL can be shared freely. Cost is bounded by reserved concurrency, not by who can access it.

Constant-Time Secret Checks: Both the Gateway authorizer and origin-secret validation use constant-time comparison, preventing timing attacks against the shared secret.

📊Result

Key Capabilities

$7
Per 1,000 Web Searches (Only When Model Searches)
0
Third-Party Search SDKs or API Keys
2
Models Supported (Sonnet 4.6 + Haiku 4.5)
16
Offline Test Functions (No AWS Required)

What the Demo Proves

Suggested Demo Flow

Enterprise Impact

Strategic Impact: Agent Web Search proves that grounding LLM responses in real-time web data does not require third-party search providers, external API keys, or custom response-parsing code. One managed connector on an AgentCore Gateway, discovered dynamically via MCP, governed by server-side policy, and billed at $7 per 1,000 searches - with the model itself deciding when searching adds value.

🎥Demo Video

Watch Agent Web Search in action - see the side-by-side comparison between training-data-only responses and real-time grounded responses with AgentCore Gateway Web Search:

💡Key Learnings & Best Practices

Architecture Insights

Agent Behavior Insights

Security Insights

← Back to Portfolio