Skip to content

Building a Sales Intelligence Agent with Brave Search API and AWS Bedrock AgentCore

10 minute read
Content level: Intermediate
0

Using the Brave Search API directly for your Bedrock Agentcore Applications

Sales teams spend hours manually researching prospects — searching for company overviews, tracking down decision makers, and scanning recent news before every outreach. It's repetitive, structured work that follows the same pattern every time: search, read, synthesize, repeat. That makes it a natural fit for an AI agent.

In this post, we show you how to build a sales intelligence agent that uses the Brave Search API directly from an agent running on AWS Bedrock AgentCore. Give it a company name, and it runs three targeted searches — company overview, key executives, and recent news — then returns a structured prospect profile your sales team can act on immediately. The entire agent is under 100 lines of Python, deploys with a single command, and uses Brave Search's free tier for up to 2,000 queries per month.

What makes this approach different from the MCP pattern covered in our companion post on the Market Research Agent is that this agent calls the Brave Search API directly — no intermediate MCP runtime required. This is a simpler architecture when you want full control over how search queries are constructed and results are processed, and when your agent is the only consumer of the search API.

Solution overview

The architecture is straightforward: a single Python agent running on AgentCore makes direct HTTPS calls to the Brave Search API.

User Request:
  ./test_agent.sh "Stripe"
         │
         ▼
┌─────────────────────────────────────────────────┐
│         Sales Intelligence Agent                │
│  (Python on AWS Bedrock AgentCore Runtime)      │
│                                                 │
│  ┌─────────────────────────────────────────┐    │
│  │  3 parallel Brave Search API calls:     │    │
│  │  • "{company} company overview"         │    │
│  │  • "{company} CEO executives"           │    │
│  │  • "{company} news" (past month)        │    │
│  └─────────────────────────────────────────┘    │
└────────────────┬────────────────────────────────┘
                 │ HTTPS + API key
                 ▼
         ┌───────────────┐
         │ Brave Search  │
         │     API       │
         └───────────────┘
                 │
                 ▼
    Sales Intelligence Report
    • Company overview & valuation
    • Key decision makers
    • Recent news & developments

The agent stores the Brave Search API key in a local config file that gets bundled into the container at deploy time. This is the simplest approach for a single-agent setup. For multi-agent architectures where multiple agents need search access, consider the MCP pattern described in the companion post, which centralizes API key management in a dedicated runtime.

Solution guidance

This solution uses the following AWS services and third-party components:

  • AWS Bedrock AgentCore Runtime — Managed runtime for deploying AI agents as containerized workloads
  • AgentCore Starter Toolkit — CLI tool that handles configuration, container builds, and deployment
  • AWS CodeBuild — Builds the agent's Docker container image automatically
  • Amazon ECR — Stores the container images
  • Amazon CloudWatch — Provides logs and observability
  • Brave Search API — External web search API that powers the research queries
  • Kiro AI IDE — Development environment used to build this agent
  • uv — Fast Python package manager used for dependency management

Prerequisites

Before starting, ensure you have:

  • An AWS account with permissions to create IAM roles, ECR repositories, CodeBuild projects, and Bedrock AgentCore runtimes
  • AWS CLI installed and configured (aws configure)
  • A Brave Search API key — get one free at brave.com/search/api (free tier includes 2,000 queries/month)
  • Git for cloning the repository

Verify your environment:

aws --version
aws sts get-caller-identity

Note: You do not need Python, Docker, or uv installed locally. The setup script installs uv automatically, and all container builds happen on AWS CodeBuild.

Part 1: Understand the agent code

Before deploying, let's walk through the agent code in src/sales_agent.py. The entire agent is under 100 lines.

1.1: The AgentCore application

The agent uses the BedrockAgentCoreApp class from the AgentCore SDK to define its entrypoint:

from bedrock_agentcore.runtime import BedrockAgentCoreApp
import requests
import os

app = BedrockAgentCoreApp()

1.2: Brave Search integration

The search_brave function makes direct HTTPS calls to the Brave Search API. It reads the API key from a config file, constructs the query, and returns structured JSON results:

def search_brave(query, count=10, freshness='pw'):
    api_key = get_brave_api_key()
    params = {"q": query, "count": count, "freshness": freshness}
    url = "https://api.search.brave.com/res/v1/web/search"
    headers = {"Accept": "application/json", "X-Subscription-Token": api_key}

    response = requests.get(url, headers=headers, params=params, timeout=10)
    response.raise_for_status()
    return response.json()

The freshness parameter is key for sales intelligence. The agent uses 'pw' (past week) for company overviews and executive searches to get current information, and 'pm' (past month) for news to capture recent developments without missing important stories.

1.3: The research orchestration

The agent's entrypoint receives a company name and runs three targeted searches:

@app.entrypoint
def invoke(payload: dict) -> dict:
    company_name = payload.get('company_name') or payload.get('prompt', '')

    # Three research angles
    company_info = search_brave(f"{company_name} company overview", count=5)
    decision_makers = search_brave(f"{company_name} CEO executives", count=5)
    recent_news = search_brave(f"{company_name} news", count=5, freshness='pm')

    # Format and return structured report
    return {
        'answer': format_report(company_name, company_info, decision_makers, recent_news),
        'company': company_name,
        'status': 'success'
    }

Each search targets a different aspect of the prospect profile. The results are formatted into a structured report with sections for company intelligence, decision makers, and recent news — the three things a sales rep needs before making first contact.

Part 2: Deploy the agent

Step 2.1: Clone the repository

git clone https://github.com/aws-samples/sample-brave-demos.git
cd sample-brave-demos/BraveSearchKiroSalesAgent/BraveSearchKiroSalesAgent

Step 2.2: Run the setup script

The repository includes a single setup script that handles everything:

chmod +x setup_and_deploy.sh
./setup_and_deploy.sh

The script will:

  • ✅ Install uv package manager if not present
  • ✅ Verify AWS credentials
  • ✅ Prompt for your Brave Search API key and save it to config/api_key.txt
  • ✅ Configure the agent with the AgentCore Starter Toolkit
  • ✅ Deploy to AgentCore Runtime via CodeBuild (takes 5–10 minutes)
  • ✅ Create all necessary AWS resources (ECR, CodeBuild, IAM roles, CloudWatch)

Step 2.3: What gets created

The AgentCore Starter Toolkit creates these AWS resources automatically:

  1. AgentCore Runtime Instance — Managed container service hosting your agent
  2. CodeBuild Project — Builds the Docker image from your agent code
  3. ECR Repository — Stores the container images
  4. S3 Bucket — Stores build artifacts
  5. IAM Roles — Permissions for CodeBuild and AgentCore Runtime
  6. CloudWatch Logs — Agent execution logs

All resources are managed by the toolkit and can be removed with a single command.

Cost estimate: Most resources fall within AWS free tier. Typical costs:

  • CodeBuild: ~$0.10 per build (first 100 minutes/month free)
  • AgentCore Runtime: Pay per invocation
  • ECR storage: ~$0.10/GB/month
  • S3 storage: < $0.01/month

Part 3: Test the agent

Step 3.1: Run a test query

./test_agent.sh "Stripe"

Step 3.2: Review the results

The agent returns a structured prospect profile:

SALES PROSPECT PROFILE: Stripe

============================================================

📊 COMPANY INTELLIGENCE:
1. Stripe - Wikipedia
   https://en.wikipedia.org/wiki/Stripe_(company)

2. Stripe | Financial Infrastructure for the Internet
   https://stripe.com/

3. Stripe Company Profile - Craft.co
   https://craft.co/stripe

============================================================

👥 DECISION MAKERS:
1. Patrick Collison - CEO & Co-founder of Stripe
   https://www.linkedin.com/in/patrickcollison

2. John Collison - President & Co-founder of Stripe
   https://stripe.com/about

============================================================

📰 RECENT NEWS:
1. Stripe launches new AI-powered fraud detection tools
   https://techcrunch.com/...

2. Stripe expands to 5 new markets in Southeast Asia
   https://www.reuters.com/...

============================================================

Status: Complete

Step 3.3: Try additional companies

./test_agent.sh "OpenAI"
./test_agent.sh "Anthropic"
./test_agent.sh "Databricks"

Each query performs fresh real-time searches via the Brave Search API. Results reflect the latest publicly available information.

Step 3.4: Test locally (optional)

For development iteration without redeploying, you can test locally:

uv run python test_local.py "Stripe"

Or start the local dev server:

uv run src/sales_agent.py

Then in another terminal:

curl -X POST http://localhost:8000/invoke \
  -H "Content-Type: application/json" \
  -d '{"company_name": "Stripe"}'

Part 4: Customize the agent

Change research angles

Edit src/sales_agent.py to modify the search queries. For example, to add a competitive landscape search:

competitors = search_brave(f"{company_name} competitors alternatives", count=5)

Adjust result freshness

The freshness parameter controls how recent the results are:

  • 'pd' — Past day
  • 'pw' — Past week (default for company/executive searches)
  • 'pm' — Past month (default for news)
  • 'py' — Past year

Adjust result count

Change the count parameter in each search_brave call to get more or fewer results per section.

Redeploy after changes

uv run agentcore launch

Subsequent deployments take 2–3 minutes with cached dependencies.

Part 5: Monitor the agent

View CloudWatch logs

Stream agent execution logs in real time:

uv run agentcore logs

Check agent status

uv run agentcore status

GenAI Observability dashboard

AWS Bedrock AgentCore integrates with CloudWatch's GenAI Observability dashboard, providing visibility into request volume, latency, success and error rates. Navigate to CloudWatch → GenAI Observability → Agent Core in the AWS Management Console.

Part 6: Clean up resources

To avoid ongoing charges, remove all resources when done testing:

python cleanup_aws.py

This removes the AgentCore runtime, CodeBuild project, ECR repository, S3 bucket, IAM roles, and CloudWatch log groups.

Alternatively, use the AgentCore CLI directly:

uv run agentcore destroy

Direct API vs. MCP: When to use which

This post demonstrates the direct API integration pattern. The companion post demonstrates the MCP pattern. Here's when to use each:

Direct API (this post)MCP Runtime (companion post)
Best forSingle agent calling one APIMultiple agents sharing an API
API key managementIn agent config fileCentralized in MCP runtime
Setup complexitySingle script, no dependenciesRequires MCP runtime first
Key rotationRedeploy agentUpdate MCP runtime only
AuthenticationAPI key in HTTPS headerIAM-authenticated agent-to-agent
Lines of code~90 lines~80 lines + MCP runtime

Use the direct pattern when simplicity matters and you have a single agent. Use MCP when you have multiple agents that need search access, or when you want to centralize credential management and leverage IAM for agent-to-agent authentication.

Conclusion

With under 100 lines of Python and a single deployment command, you have a production-ready sales intelligence agent that can research any company in seconds. The Brave Search API provides fresh, structured web results, and AgentCore handles all the infrastructure — container builds, hosting, scaling, and observability — so you can focus on the research logic.

The agent is intentionally simple. It runs three searches, formats the results, and returns a report. But that simplicity is the point: it's a foundation you can extend. Add more search angles, integrate with your CRM, pipe the output into an LLM for summarization, or chain it with other agents in a larger workflow. The Brave Search API and AgentCore Runtime give you the building blocks; what you build with them is up to you.

The sample code for this post is available on GitHub at aws-samples/sample-brave-demos.

AWS
EXPERT
published a month ago188 views