Documentation
¶
Index ¶
- Constants
- func GetConfiguredProviders() []string
- func GetProviderMode() string
- func IsEnabled() bool
- type Input
- type Output
- type RunnerFn
- type Tool
- func (t *Tool) BackfillInput(ctx context.Context, input map[string]any) map[string]any
- func (t *Tool) Call(ctx context.Context, input tool.CallInput, permissionCheck types.CanUseToolFn) (tool.CallResult, error)
- func (t *Tool) CheckPermissions(ctx context.Context, input map[string]any, toolCtx tool.ToolUseContext) types.PermissionResult
- func (t *Tool) Definition() tool.Definition
- func (t *Tool) Description(ctx context.Context) (string, error)
- func (t *Tool) FormatResult(data any) string
- func (t *Tool) IsAvailableNow() bool
- func (t *Tool) IsConcurrencySafe(input map[string]any) bool
- func (t *Tool) IsEnabled() bool
- func (t *Tool) IsReadOnly(input map[string]any) bool
- func (t *Tool) PreparePermissionMatcher(ctx context.Context, input map[string]any) (func(string) bool, error)
- func (t *Tool) SetRunner(fn RunnerFn)
- func (t *Tool) ValidateInput(ctx context.Context, input map[string]any) (map[string]any, error)
Constants ¶
const SearchHint = "search the web for current information"
const ToolDescription = `` /* 1538-byte string literal not displayed */
const ToolName = "web_search"
ToolName is the name of the web search tool.
Variables ¶
This section is empty.
Functions ¶
func GetConfiguredProviders ¶
func GetConfiguredProviders() []string
GetConfiguredProviders returns the list of configured providers.
func GetProviderMode ¶
func GetProviderMode() string
GetProviderMode returns the current provider mode.
Types ¶
type Input ¶
type Input = searchcore.Input
type Output ¶
type Output = searchcore.Output
type RunnerFn ¶
type RunnerFn func(ctx context.Context, query string, allowedDomains, blockedDomains []string) (Output, error)
RunnerFn is an optional hook that replaces the env-based provider chain. It receives the query and domain filters and must return a full Output. When nil the tool falls back to the env-configured provider chain.
func NewRunnerFromKeys ¶
NewRunnerFromKeys builds a RunnerFn that uses explicit per-user provider API keys instead of reading from process environment. This enables safe concurrent job execution across multiple owners without os.Setenv races. keys must be keyed by provider name: "tavily", "exa", "jina", "langsearch".
type Tool ¶
type Tool struct {
// contains filtered or unexported fields
}
Tool implements the WebSearch tool.
func NewToolWithProvider ¶
func NewToolWithProvider(provider searchproviders.SearchProvider) *Tool
NewToolWithProvider creates a WebSearch tool with an explicit provider. Deprecated: Use the provider chain system instead.
func (*Tool) BackfillInput ¶
BackfillInput enriches a shallow clone of the parsed input with derived permission fields.
func (*Tool) Call ¶
func (t *Tool) Call(ctx context.Context, input tool.CallInput, permissionCheck types.CanUseToolFn) (tool.CallResult, error)
Call executes the web search using the provider chain.
func (*Tool) CheckPermissions ¶
func (t *Tool) CheckPermissions(ctx context.Context, input map[string]any, toolCtx tool.ToolUseContext) types.PermissionResult
CheckPermissions applies shared web policy before delegating any remaining decision to the global permission pipeline.
func (*Tool) Definition ¶
func (t *Tool) Definition() tool.Definition
Definition returns the tool definition.
func (*Tool) Description ¶
Description returns the tool description.
func (*Tool) FormatResult ¶
FormatResult serialises the tool output into the tool_result content string.
func (*Tool) IsAvailableNow ¶
IsAvailableNow returns true when a search provider is actually available at the current moment — either because a per-request runner was injected by the backend (DB-backed providers) or because at least one env-based provider is configured (TAVILY_API_KEY, EXA_API_KEY, etc.). This is the dynamic check used to hide the tool from the model when no provider is configured, without interfering with session map registration.
func (*Tool) IsConcurrencySafe ¶
IsConcurrencySafe reports that WebSearch requests can run concurrently.
func (*Tool) IsEnabled ¶
IsEnabled always returns true so that web_search is registered in the session tool map at session creation time. Actual provider availability is checked at request time via IsAvailableNow, which is called by EffectiveToolSurface after any per-request runner has been injected.
func (*Tool) IsReadOnly ¶
IsReadOnly reports that WebSearch does not modify state.
func (*Tool) PreparePermissionMatcher ¶
func (t *Tool) PreparePermissionMatcher(ctx context.Context, input map[string]any) (func(string) bool, error)
PreparePermissionMatcher compiles content-specific permission matching for domain- and provider-aware search rules.