Overview
Integration details
Tool features
Available tools
Setup
The integration lives in thelangchain-aws package, which wraps the bedrock-agentcore SDK.
langchain-aws 1.7.9 or later and bedrock-agentcore 1.23.0 or later. Calling the Web Search API without a gateway needs langchain-aws 1.9.3 or later and bedrock-agentcore 1.26.0 or later. On earlier versions, the toolkit requires a gateway.
Install bedrock-agentcore explicitly, as above. langchain_aws.tools imports the web search toolkit inside a try/except ImportError, so on an install without bedrock-agentcore, or with a version below 1.23.0, the export is skipped rather than raising, and create_web_search_toolkit is simply absent from langchain_aws.tools. If the import fails, check both installed versions before anything else.
Optional: create a gateway with a web search target
The Web Search API needs no resources, so skip this step unless you want to search through an AgentCore Gateway target instead. You only do this once, and the same gateway serves every agent in the account.authorizerType="AWS_IAM" is what makes the caller’s own IAM permissions gate the gateway. NONE disables inbound authorization altogether, leaving the gateway callable by anyone who learns its URL and billed to your account.
The target is named amazon-web-search by default, and Gateway prefixes every tool with its target name, so the tool on the gateway is amazon-web-search___WebSearch. The toolkit finds it for you; the name matters only if you go looking for it in the gateway’s tool list.
The Web Search API is available in us-east-1, us-east-2, us-west-2, eu-west-1, ap-northeast-1, and ap-southeast-2. The Web Search Tool connector is offered in a different set of Regions. The service documentation carries the current lists.
Credentials
With the Web Search API, your own credentials needbedrock-agentcore:InvokeWebSearch on arn:aws:bedrock-agentcore:<region>:aws:tool/web-search.v1. For the full setup, see Get started with AgentCore Web Search.
Through a gateway, two different principals each need one permission, and mixing them up is the most common setup error:
- Your own credentials need
bedrock-agentcore:InvokeGatewayon the gateway ARN. - The gateway’s execution role needs
bedrock-agentcore:InvokeWebSearchonarn:aws:bedrock-agentcore:<region>:aws:tool/web-search.v1, and a trust policy that letsbedrock-agentcore.amazonaws.comassume it. It needs nothing else.
aws:SourceArn to a region, it has to be the gateway’s region. A mismatch is accepted when the gateway is created and surfaces only on the first search, as Failed to obtain execution role credentials.
It’s also helpful (but not needed) to set up LangSmith for best-in-class observability:
Instantiation
The factory is synchronous, unlike the browser and code interpreter factories in this package, because a search needs no session to be set up first.gateway_id, by gateway_arn, or by gateway_endpoint if you already know the MCP URL. A gateway_arn carries its own region. With a gateway_id, pass region to match the gateway’s region, or it will default to us-east-1.
Passing target_name saves a tool discovery round trip on the first search. Use it if you named the target something other than the default:
Invocation
Direct tool usage
12:31PM, Friday, July 24 2026, PDT.
Use within an agent
Filtering results
The model can narrow a search by domain and by publication date. Both are arguments on the tool, so the model can set them itself when the question calls for it:https://github.com, github.com/boto/boto3, or *.github.com. Both date bounds are inclusive.
include_domains can only narrow a search, never widen it: if the gateway target was created with its own include list, the two intersect, and disjoint lists return nothing.
To enforce a policy that the agent cannot relax, set it on the toolkit, as in the next section. Through a gateway, you can also set a domain policy on the target. Those lists are applied server-side and are not visible to the agent:
Rules the model cannot change
Rules set on the toolkit apply to every search, on either route. A call from the model can narrow them but never widen them:include_domains,exclude_domains,published_after, andpublished_beforeapply to every search. The model’s exclude list is added to the toolkit’s, its include list is intersected with the toolkit’s, and its date bounds apply only when they are stricter.model_filters=Falsegives the model a query-only argument schema.max_searchescaps the searches one toolkit runs. After that, the tool returnsSearch limit of 4 reached. Answer with what you have.return_sources=Truereturns results as a tool artifact: a list of dicts withtitle,url,published_date,published_at, andtext.
Error handling
A failed search raisesToolException, so a retry wrapper such as Runnable.with_retry() sees it as a failure rather than as a successful call that returned an error message.
To let the model read the message and correct its own query instead, opt in per tool:
Releasing the client
The toolkit holds a client, whichclose() releases. It also works as a context manager:
API reference
For detailed documentation of all features and configurations, see:- langchain-aws API reference
- AgentCore Web Search API documentation
- AgentCore Web Search tool documentation
- AgentCore Gateway tool naming
Connect these docs to your agent of choice via MCP for real-time answers.

