webtools

package
v1.833.21 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package webtools gives every Responses-API agent the three capabilities the platform already serves and no agent could reach: web search, page fetch, and deep research.

The registry held five time tools, so an agent asking to search the web had nothing to call — while /v1/websearch/search, /v1/crawl and /v1/ask were live the whole time. These are those endpoints as tools.

WHY EVERY BACKEND IS A SEAM. This package is a LEAF and must stay one: `object` imports `agent`, `agent` imports this registry, so a tool that reached into object for crawl closed the loop — agent → builtin_tool → web → object → agent — and the module stopped compiling. Search and research are served by the HOST (hanzoai/cloud), which imports this module, so they could never have been direct calls either. All three are installed from outside: crawl by this module's own bootstrap, search and research by the host at mount time, beside the balance and tier readers it already installs.

It is also the shape this codebase learned the hard way: the ai module once reached its own platform over api.hanzo.ai, which carries a customer credential and answered 401 to a service, and every completion fail-closed at 503 on a perfectly healthy pod. The edge is for customers; in-process is for us.

UNSET IS REFUSED, NEVER FAKED. A capability the host did not install answers that it is unavailable in this deployment. An agent told "no results" would conclude the web holds nothing on the subject and answer from memory — which is a fabricated answer with a confident tone. Absent and empty are different facts.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotConfigured = errors.New("this capability is not available in this deployment")

ErrNotConfigured is what a tool answers when the host installed no backend for it. It names the deployment, not the query, so a model cannot read it as "nothing found".

Functions

func SetFetch

func SetFetch(f FetchFunc)

SetFetch installs the page fetcher (nil clears it).

func SetResearch

func SetResearch(f ResearchFunc)

SetResearch installs the host's deep research (nil clears it).

func SetSearch

func SetSearch(f SearchFunc)

SetSearch installs the host's web search (nil clears it).

Types

type FetchFunc

type FetchFunc func(ctx context.Context, urls []string) ([]FetchResult, error)

FetchFunc fetches pages as Markdown. Installed by this module's bootstrap.

func Fetch

func Fetch() FetchFunc

Fetch returns the installed fetcher, or nil.

type FetchResult

type FetchResult struct {
	URL      string
	Title    string
	Markdown string
	Success  bool
}

FetchResult is one fetched page, reduced to what a model can read and cite.

type FetchTool

type FetchTool struct{}

func (*FetchTool) Execute

func (t *FetchTool) Execute(ctx context.Context, args map[string]interface{}) (*protocol.CallToolResult, error)

func (*FetchTool) GetDescription

func (t *FetchTool) GetDescription() string

func (*FetchTool) GetInputSchema

func (t *FetchTool) GetInputSchema() interface{}

func (*FetchTool) GetName

func (t *FetchTool) GetName() string

type ResearchFunc

type ResearchFunc func(ctx context.Context, question string) (string, error)

ResearchFunc runs a grounded, multi-source investigation and returns the report with its citations inline. Installed by the host.

func Research

func Research() ResearchFunc

Research returns the installed research, or nil.

type ResearchTool

type ResearchTool struct{}

func (*ResearchTool) Execute

func (t *ResearchTool) Execute(ctx context.Context, args map[string]interface{}) (*protocol.CallToolResult, error)

func (*ResearchTool) GetDescription

func (t *ResearchTool) GetDescription() string

func (*ResearchTool) GetInputSchema

func (t *ResearchTool) GetInputSchema() interface{}

func (*ResearchTool) GetName

func (t *ResearchTool) GetName() string

type SearchFunc

type SearchFunc func(ctx context.Context, query string, limit int) ([]SearchResult, error)

SearchFunc runs a web meta-search. Installed by the host.

func Search() SearchFunc

Search returns the installed search, or nil.

type SearchResult

type SearchResult struct {
	Title   string `json:"title"`
	URL     string `json:"url"`
	Snippet string `json:"snippet,omitempty"`
}

SearchResult is one web hit. Deliberately the smallest shape that is useful to a model: enough to cite, not enough to bloat a context window.

type SearchTool

type SearchTool struct{}

func (*SearchTool) Execute

func (t *SearchTool) Execute(ctx context.Context, args map[string]interface{}) (*protocol.CallToolResult, error)

func (*SearchTool) GetDescription

func (t *SearchTool) GetDescription() string

func (*SearchTool) GetInputSchema

func (t *SearchTool) GetInputSchema() interface{}

func (*SearchTool) GetName

func (t *SearchTool) GetName() string

Jump to

Keyboard shortcuts

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