Repository navigation
fix(policy): bind web-search preset endpoints to their provider #13883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0cd0652
fix(policy): bind web-search preset endpoints to their provider
laitingsheng a47d343
fix(policy): bind Tavily credentials only to the preset endpoint
laitingsheng bddee37
fix(policy): verify endpointless Tavily profile before preset binding
laitingsheng 7c3606e
fix(policy): unify web-search preset binding and verify rebuild rewrite
laitingsheng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
managed-inference/provider-profiles/tavily-policy-binding-v1.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Endpointless carrier for a Tavily credential bound by the tavily policy preset. | ||
| # OpenShell withholds a static credential stored under a profile that declares | ||
| # no endpoints until the sandbox policy names that profile's provider in an | ||
| # endpoint credential_binding. A profile that already declares endpoints cannot | ||
| # supply that binding. The network contract stays with the preset. | ||
| id: tavily-policy-binding-v1 | ||
| display_name: Tavily credential for policy binding | ||
| description: Endpointless profile for a Tavily credential bound by the tavily policy preset | ||
| category: agent | ||
| credentials: | ||
| - name: api_key | ||
| description: Tavily Search API key | ||
| env_vars: | ||
| - TAVILY_API_KEY | ||
| required: true | ||
| auth_style: bearer | ||
| header_name: authorization | ||
| query_param: '' | ||
| endpoints: [] | ||
| binaries: [] | ||
| inference_capable: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
src/lib/adapters/config/live-export-search-source-test-fixture.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { mockSupportedLiveSource, raw } from "../../../../test/support/config-export-harness"; | ||
| import { | ||
| endpointlessTavilyProfile, | ||
| managedBraveProfile, | ||
| managedTavilyProfile, | ||
| } from "../../../../test/fixtures/openshell-provider-profile"; | ||
| import { buildManagedStartupProfile } from "../../onboard/managed-startup/profile-builder"; | ||
| import type { SandboxEntry } from "../../state/registry/types"; | ||
| import { | ||
| braveProvider, | ||
| entry, | ||
| imageRef, | ||
| inventory, | ||
| provider, | ||
| startupInput, | ||
| } from "./live-export-source-test-fixture"; | ||
|
|
||
| export function tavilyProfile(agent: "openclaw" | "hermes") { | ||
| return agent === "hermes" ? managedTavilyProfile(agent) : endpointlessTavilyProfile(); | ||
| } | ||
|
|
||
| function hermesDashboard() { | ||
| return { | ||
| agent: "hermes" as const, | ||
| mode: "disabled" as const, | ||
| url: "http://127.0.0.1:18789", | ||
| browserUrl: "http://127.0.0.1:18789", | ||
| publicPort: null, | ||
| internalPort: null, | ||
| tuiEnabled: false as const, | ||
| }; | ||
| } | ||
|
|
||
| function searchStartup(searchProvider: "brave" | "tavily", agent: "openclaw" | "hermes") { | ||
| return buildManagedStartupProfile({ | ||
| ...startupInput, | ||
| agent, | ||
| ...(agent === "hermes" | ||
| ? { | ||
| inference: { ...startupInput.inference, primaryModelRef: null, compatibility: null }, | ||
| dashboard: hermesDashboard(), | ||
| } | ||
| : {}), | ||
| webSearch: { fetchEnabled: true, provider: searchProvider }, | ||
| }); | ||
| } | ||
|
|
||
| function searchRegistry( | ||
| searchProvider: "brave" | "tavily", | ||
| agent: "openclaw" | "hermes", | ||
| runtimeImage: string, | ||
| built: ReturnType<typeof searchStartup>, | ||
| ) { | ||
| return { | ||
| ...entry, | ||
| agent, | ||
| imageTag: runtimeImage, | ||
| ...(agent === "hermes" ? { hermesApiPort: 8642 } : {}), | ||
| webSearchEnabled: true, | ||
| webSearchProvider: searchProvider, | ||
| workload: { | ||
| ...(entry.workload as Extract< | ||
| NonNullable<SandboxEntry["workload"]>, | ||
| { kind: "managed-image" } | ||
| >), | ||
| reference: runtimeImage, | ||
| encodedProfile: built.encodedProfile, | ||
| startupProfileSha256: built.startupProfileSha256, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| function searchProviderRow(searchProvider: "brave" | "tavily", agent: "openclaw" | "hermes") { | ||
| const base = braveProvider(); | ||
| const profile = searchProvider === "brave" ? managedBraveProfile() : tavilyProfile(agent); | ||
| const providerName = `alpha-${searchProvider}-search`; | ||
| return { | ||
| providerName, | ||
| profile, | ||
| search: { | ||
| ...base, | ||
| provider: { | ||
| ...base.provider, | ||
| metadata: { ...base.provider.metadata, name: providerName }, | ||
| type: profile.id, | ||
| credentials: Object.defineProperty( | ||
| {}, | ||
| searchProvider === "brave" ? "BRAVE_API_KEY" : "TAVILY_API_KEY", | ||
| { | ||
| enumerable: true, | ||
| get: base.readCredential, | ||
| }, | ||
| ), | ||
| }, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| export function mockSearchLiveSource( | ||
| searchProvider: "brave" | "tavily", | ||
| agent: "openclaw" | "hermes" = "openclaw", | ||
| ) { | ||
| const runtimeImage = | ||
| agent === "hermes" ? imageRef.replace("openclaw-sandbox", "hermes-sandbox") : imageRef; | ||
| const built = searchStartup(searchProvider, agent); | ||
| mockSupportedLiveSource(3, 3, searchRegistry(searchProvider, agent, runtimeImage, built)); | ||
| const { providerName, profile, search } = searchProviderRow(searchProvider, agent); | ||
| raw.getProviderProfile.mockResolvedValue({ profile }); | ||
| raw.getProvider.mockImplementation(async ({ name }: { name: string }) => | ||
| name === providerName ? { provider: search.provider } : provider(), | ||
| ); | ||
| raw.getSandbox.mockResolvedValue({ | ||
| sandbox: { | ||
| ...inventory().sandbox, | ||
| spec: { template: { image: runtimeImage }, providers: [providerName] }, | ||
| }, | ||
| }); | ||
| return search; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.