websearchtool

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package websearchtool implements the WebSearch tool.

Unlike most tools that call external APIs directly, WebSearch delegates to Anthropic's native web_search_20250305 server-side tool. It makes a secondary streaming API call with only the native search tool declared, then assembles the results (text, citations, search hits) into a single text block returned to the main agent.

Mirrors src/tools/WebSearchTool/WebSearchTool.ts. max_uses=8 is hardcoded to match the TS implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Input

type Input struct {
	Query          string   `json:"query"`
	AllowedDomains []string `json:"allowed_domains,omitempty"`
	BlockedDomains []string `json:"blocked_domains,omitempty"`
}

Input is the typed view of the JSON input.

type Tool

type Tool struct {
	// contains filtered or unexported fields
}

Tool implements the WebSearch tool.

func New

func New(client *api.Client) *Tool

New returns a WebSearch tool backed by the given API client.

func (*Tool) Description

func (*Tool) Description() string

func (*Tool) Execute

func (t *Tool) Execute(ctx context.Context, raw json.RawMessage) (tool.Result, error)

Execute runs a web search via Anthropic's native search tool and returns a formatted text block with results and sources.

func (*Tool) InputSchema

func (*Tool) InputSchema() json.RawMessage

func (*Tool) IsConcurrencySafe

func (*Tool) IsConcurrencySafe(json.RawMessage) bool

func (*Tool) IsReadOnly

func (*Tool) IsReadOnly(json.RawMessage) bool

func (*Tool) Name

func (*Tool) Name() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL