Skip to content

feat(tools): add AgentCore Web Search as a Strands Agents tool - #672

Closed
sundargthb wants to merge 1 commit into
aws:mainfrom
sundargthb:tools/strands-web-search
Closed

sundargthb wants to merge 1 commit into
aws:mainfrom
sundargthb:tools/strands-web-search

Conversation

@sundargthb

@sundargthb sundargthb commented Sep 22, 2026

Copy link
Copy Markdown
Member

Description

Adds AgentCoreWebSearch, exposing the AgentCore Web Search tool as a Strands Agents tool. Placement follows memory/integrations/strands, payments/integrations/strands and gateway/integrations/strands: a subpackage behind the existing strands-agents extra, reached only by explicit import. No pyproject.toml change, and a base install is unaffected.

from strands import Agent

from bedrock_agentcore.tools.integrations.strands import AgentCoreWebSearch

with AgentCoreWebSearch(region="us-east-1", gateway_id="my-gateway-abc123") as search:
    agent = Agent(tools=[search.web_search])
    agent("What changed in the most recent boto3 release?")

Draft for one reason: the tests in tests_integ/ have not been run. I don't currently have credentials for an account entitled to the web search connector, so I'm not claiming this is verified against a live gateway. Marking ready once they've run.

Two behaviours worth a look in review

region is defaulted only when no region and no gateway ARN were given. WebSearchClient does region = region or arn_region, so filling a default in here unconditionally would silently send a eu-west-1 gateway's traffic to us-east-1.

A failed search raises rather than returning the message as a result. The Strands executor converts the exception to a status: "error" tool result, so the agent keeps running and the model can react. Returning "Web search failed: ..." as a successful result is indistinguishable to the model from a search that found nothing.

I checked both by mutating the source and confirming exactly one test failed each time, rather than only that the suite passes.

One forward-compatibility note: which transport is used stays inside WebSearchClient. Every gateway argument here is optional and only the ones supplied are forwarded, so the direct web search API will work through the same call without a signature change in this module.

Testing

$ uv run pytest tests/bedrock_agentcore/tools/integrations -q --cov=src/bedrock_agentcore/tools/integrations --cov-report=term-missing
24 passed
src/bedrock_agentcore/tools/integrations/strands/web_search.py   69   0   24   0   100%

$ uv run pytest tests/ -q
3568 passed, 10 skipped, 4 xpassed

$ uv run ruff check src tests tests_integ
All checks passed!

$ uv run ruff format --check src tests tests_integ
341 files already formatted

$ uv run mypy src/bedrock_agentcore/tools/integrations/
Success: no issues found in 3 source files

tests_integ/tools/integrations/strands/test_web_search_integration.py is not in that run. It needs WEB_SEARCH_GATEWAY_ID pointing at a gateway with a web search target, on an account entitled to the connector.

Related

@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Sep 22, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@889615f). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #672   +/-   ##
=======================================
  Coverage        ?   89.60%           
=======================================
  Files           ?      125           
  Lines           ?    10783           
  Branches        ?     1692           
=======================================
  Hits            ?     9662           
  Misses          ?      733           
  Partials        ?      388           
Flag Coverage Δ
unittests 89.60% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Exposes the web search tool as a single Strands tool, alongside the existing
memory, payments and gateway Strands integrations, behind the same
strands-agents extra. Attributed with integration_source="strands".

Which transport is used stays inside WebSearchClient. Every gateway argument
here is optional and only the ones supplied are forwarded, so the direct web
search API will work through the same call without a signature change.

Two behaviours the tests pin down:

- region is defaulted only when no region and no gateway ARN were given. The
  client prefers an explicit region over the ARN's, so defaulting it
  unconditionally sends a eu-west-1 gateway's traffic to us-east-1.
- a failed search raises rather than returning the message as a result. The
  Strands executor turns that into a status=error tool result, which a model can
  react to; a successful result reading "search failed" is indistinguishable to
  it from a search that found nothing.

Unit tests cover the module to 100% branch coverage. The integration tests need
a gateway with a web search target and have not been run.
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Sep 22, 2026
@sundargthb

Copy link
Copy Markdown
Member Author

Superseded by #673, same commit pushed as a branch on this repo so the integration test jobs can actually run. The fork variant could not run them: integration-testing.yml triggers on pull_request_target and actions/checkout@v6 refuses to check out fork code in that context, so all ten Test (<group>) jobs failed at the checkout step in under 11 seconds.

This branch was successfully deployed

1 active deployment
auto-approve c42eb688 Deployed Sep 22, 2026 by sundargthb via Test (gateway) #1588
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/l PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants