Skip to content

feat(gateway): add create_web_search_target() helper - #656

Open
sundargthb wants to merge 2 commits into
mainfrom
feat/gateway-web-search-target
Open

feat(gateway): add create_web_search_target() helper#656
sundargthb wants to merge 2 commits into
mainfrom
feat/gateway-web-search-target

Conversation

@sundargthb

@sundargthb sundargthb commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Description

Adds GatewayClient.create_web_search_target(), a typed one-call helper for wiring the managed web-search connector to a gateway.

GatewayClient already has helpers for the other two connectors it supports: create_knowledge_base_target() (bedrock-knowledge-bases) and create_agentic_retrieve_target() (bedrock-agentic-retrieve). Web search has no equivalent, so callers have to hand-assemble the targetConfiguration.mcp.connector block and the credential provider configuration themselves. This closes that gap and follows the same shape as its two siblings.

This is typed convenience, not new capability. create_gateway_target_and_wait() can already create the same target; the helper removes the need to know the connector ID, the tool name, and the parameter path.

Part of #654. That issue also asks for a WebSearchClient under bedrock_agentcore.tools; this PR does not include that, since the invoke-side details are still open (see Out of scope).

What it produces

client.create_web_search_target(
    gateway_identifier="gw-123",
    exclude_domains=["example.com"],
)

sends:

{
  "gatewayIdentifier": "gw-123",
  "name": "web-search",
  "targetConfiguration": {
    "mcp": {
      "connector": {
        "source": {"connectorId": "web-search"},
        "enabled": ["WebSearch"],
        "configurations": [
          {
            "name": "WebSearch",
            "parameterValues": {"domainFilter": {"exclude": ["example.com"]}}
          }
        ]
      }
    }
  },
  "credentialProviderConfigurations": [{"credentialProviderType": "GATEWAY_IAM_ROLE"}]
}

parameterValues is omitted entirely when exclude_domains is not passed or is empty, so the minimal call sends only {"name": "WebSearch"} as the configuration entry.

Where the constants come from

The two values that are not inferable from this repo are the connector ID and the tool name. Both are taken from the CLI, which already ships a web-search path:

The surrounding wire shape (enabled, configurations, GATEWAY_IAM_ROLE) mirrors create_knowledge_base_target() in this file.

Note on capitalization: the ConnectorConfiguration shape in the service model writes its example tool names in lower camel case (retrieve, webSearch), while the shipped create_knowledge_base_target() here sends Retrieve and the CLI sends WebSearch. This PR follows the shipped code rather than the doc example. This is the one thing the live run could not confirm, because validation stopped at the entitlement check before reaching tool names.

Testing

  • tests/unit/gateway/test_gateway_web_search_targets.py, 8 tests asserting the exact wire shape, the default name, parameterValues omission, **kwargs override behavior, the default credential provider, and wait_config pass-through. Modeled on the existing test_gateway_kb_targets.py.
  • tests_integ/gateway/test_gateway_web_search_targets.py, 3 opt-in tests marked @pytest.mark.integration, requiring GATEWAY_ROLE_ARN, creating and tearing down a real gateway and targets. Modeled on the existing tests_integ/gateway/test_gateway_kb_targets.py.

Full unit suite: 3412 passed, 10 skipped, 4 xpassed. ruff check and ruff format --check clean on all three files.

What the live run showed

The Test (gateway) CI job runs tests_integ/gateway against a real account in us-west-2, so the first push did exercise this against a live CreateGatewayTarget. All three tests failed with the same error:

ValidationException: An error occurred (ValidationException) when calling the
CreateGatewayTarget operation: Connector integration web-search is not available
for this account.

The request the SDK built was accepted structurally and rejected at the account entitlement check, with the service naming web-search back. The rest of the gateway suite, including the KB target tests, passed in the same run.

Two things follow, and the second one is a real limit on this PR:

  1. The connector ID is recognized by the service.
  2. Validation stops at entitlement, so this run does not confirm enabled: ["WebSearch"] or the domainFilter.exclude path. Those are still only verified against the CLI's implementation.

The second push makes the integration tests pytest.skip on that specific message and still fail on anything else, so the job reports honestly instead of red. To get the remaining verification, the integ test account needs the connector enabled, or someone on an enabled account should run:

GATEWAY_ROLE_ARN=<role> pytest tests_integ/gateway/test_gateway_web_search_targets.py

Out of scope

  • WebSearchClient in bedrock_agentcore.tools. The other built-in tools have data-plane clients because they have data-plane APIs (StartBrowserSession, StartCodeInterpreterSession). Web search is reached over MCP through a gateway, so an equivalent client needs a decision on how it signs and transports requests. Tracked in [FEATURE] Add a WebSearch client to bedrock_agentcore.tools and a create_web_search_target() helper #654.
  • Connector version. ConnectorSource accepts an optional version; neither existing connector helper exposes it, so this one does not either. Omitting it means the service picks the latest.
  • Filters other than domain exclusion. Only domainFilter.exclude is set here, because that is the only parameter with a verified path. Anything else a caller needs can go through parameter_overrides or by passing targetConfiguration directly, both of which still work.
  • Runtime parameters. Values the agent supplies per call are not admin-configured, so they are not part of this helper.

Checklist

  • Tests added
  • Lint and format clean
  • No public API removed or changed; this is additive
  • Wire shape confirmed end to end on an account with the web-search connector enabled

Unrelated CI failures

None of the red jobs on this PR touch gateway code:

Test (gateway), the job that covers this change, passes.

Adds a typed one-call helper for wiring the managed web-search connector to
a gateway, matching the existing create_knowledge_base_target() and
create_agentic_retrieve_target() helpers.

The web-search connector exposes a single WebSearch tool. The one
admin-configurable parameter is an optional list of domains to exclude from
results, sent as parameterValues.domainFilter.exclude.

Includes unit tests for the wire shape and opt-in integration tests.
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

✅ No Breaking Changes Detected

No public API breaking changes found in this PR.

@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 1, 2026
… connector

The web-search connector is enabled per account. When it is not, CreateGatewayTarget
returns ValidationException "Connector integration web-search is not available for
this account." Skip on that specific error so the suite reports honestly on accounts
without the entitlement, while still failing on any other error.
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Sep 1, 2026
@sundargthb
sundargthb deployed to auto-approve September 1, 2026 14:37 — with GitHub Actions Active
@sundargthb
sundargthb deployed to auto-approve September 1, 2026 14:37 — with GitHub Actions Active
@sundargthb
sundargthb deployed to auto-approve September 1, 2026 14:37 — with GitHub Actions Active
@sundargthb
sundargthb deployed to auto-approve September 1, 2026 14:37 — with GitHub Actions Active
@sundargthb
sundargthb deployed to auto-approve September 1, 2026 14:37 — with GitHub Actions Active
@sundargthb
sundargthb deployed to auto-approve September 1, 2026 14:37 — with GitHub Actions Active
@sundargthb
sundargthb deployed to auto-approve September 1, 2026 14:37 — with GitHub Actions Active
@sundargthb
sundargthb deployed to auto-approve September 1, 2026 14:37 — with GitHub Actions Active
@github-actions github-actions Bot removed the size/m PR size: M label Sep 1, 2026
@github-actions github-actions Bot added the size/m PR size: M label Sep 1, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Sep 1, 2026
@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 1, 2026
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant