ViteHub is still experimental. Expect bugs and breaking changes.

Web search

Add model web search or normalized web search and read tools.

webSearch() gives an Agent access to web context through an explicit mode. Use model mode for provider-native web search, or tool mode for normalized web_search and web_read tools.

Installation

Import the Capability factory from -hub/agent/capabilities and add it to defineAgent({ capabilities }). Use the configuration example below as the starting point, then tighten modes, policies, stores, and providers for the Agent boundary.

What it adds

Model mode contributes a provider tool request for web_search. Tool mode contributes web_search and web_read model-facing tools backed by a single configured search provider.

Configuration

Use model mode when the selected model provider supports provider-native web search. Tool mode requires a web search provider configuration.

server/agents/research.ts
import { defineAgent } from '@vite-hub/agent'
import { webSearch } from '@vite-hub/agent/capabilities'

export default defineAgent({
  driver: { model },
  capabilities: [
    webSearch({ mode: 'model' }),
  ],
})

Runtime behavior

Model mode adds a Provider Tool contribution and leaves search execution to the model provider. Tool mode loads the configured provider, executes normalized search requests, and reads URLs as Markdown or text.

Requirements

webSearch() requires mode: 'model' or mode: 'tool'. Model mode requires an Agent Driver and model provider that support the provider tool.

Tool mode requires the application to install askweb and configure one web search provider with any required credentials.

Driver support

Agent DriverSupport
Model-backedReceives the provider tool in model mode or web_search and web_read in tool mode.
Harness-backedRuntime requirements apply; model-facing web tools are not passed by default.
Custom-run-backedReceives prepared context; driver.run decides how to perform web access.

Inspect and verify

Inspect provider tool contributions for model mode or the Agent tool list for tool mode. Tool mode should expose web_search and web_read.

Run tool mode without askweb during development. The Capability should report the missing package and suggest model mode as the alternative.

Options

OptionTypeDefaultDescription
mode"model" | "tool"requiredUses provider-native model web search or ViteHub-managed search/read tools.
providerWebSearchProviderInputrequired in tool modeProvider name or provider options for tool mode.
provider.name"brave" | "exa" | "jina" | "searxng" | "serpapi" | "serpbase" | "tavily" | stringrequiredTool-mode web search provider.
provider.apiKeystring | unsealer | functionenv/provider defaultCredential for providers that require one.
provider.baseURLstringprovider defaultOverride provider endpoint.

Reference

Copyright © 2026