ViteHub is still experimental. Expect bugs and breaking changes.

Fetch

Expose named HTTP request tools for developer-approved endpoints.

fetch() adds model-facing HTTP tools that the developer names and defines. Use it for specific endpoints, not for unrestricted web browsing.

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

The Capability creates one tool per entry in tools. Each tool can validate input, build a request, parse JSON or text, validate the response, and transform the output.

Configuration

Define at least one named fetch tool. Keep the endpoint and method explicit.

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

export default defineAgent({
  driver: { model },
  capabilities: [
    fetch({
      tools: {
        serviceStatus: {
          description: 'Fetch current service status.',
          method: 'GET',
          url: 'https://status.example.com/api/status',
        },
      },
    }),
  ],
})

Runtime behavior

ViteHub validates the configured tool map and creates internal Agent tools. At invocation time, each tool resolves the request, executes the HTTP call, parses the configured response type, and returns either the parsed data or a transformed output.

Requirements

fetch({ tools }) requires at least one tool definition. Each tool must provide a URL directly or return one from its request resolver.

Use schemas for input and response validation when the endpoint accepts arguments or returns data that model behavior depends on.

Driver support

Agent DriverSupport
Model-backedReceives the named fetch tools.
Harness-backedRuntime requirements apply; model-facing fetch tools are not passed by default.
Custom-run-backedReceives prepared context; driver.run decides whether to call HTTP endpoints directly.

Inspect and verify

Inspect the Agent tool list and confirm only the named fetch tools appear. Run one invocation with invalid input when a schema is configured and verify the request does not leave the process.

Options

OptionTypeDefaultDescription
toolsRecord<string, FetchCapabilityToolOptions>requiredNamed fetch tools exposed to the model.
tools.*.descriptionstringFetch <name>.Tool description.
tools.*.urlstring | URLnoneStatic request URL.
tools.*.requestobject | functionnoneStatic or input-derived request definition.
tools.*.method"GET" | "HEAD" | "POST"request defaultHTTP method.
tools.*.inputSchemaStandard SchemanoneValidates model tool input before request construction.
tools.*.schemaStandard SchemanoneValidates parsed response data.
tools.*.responseType"json" | "text""json"Response parser.
tools.*.transform(data, input) => outputnoneMaps validated response data before returning it to the model.

Reference

Copyright © 2026