Agents

Define model-backed server actors with instructions, invocations, triggers, workspaces, and capabilities.

Agents are the ViteHub path for model-backed server actors. Use agents when the feature needs instructions, model execution, tools, workspace context, triggers, evaluations, or model-facing capabilities.

If you only need KV, Database, Blob, Queue, Workflow, Schedule, Sandbox, Workspace, or Env from ordinary app code, start with Server primitives.

Agent model

An Agent Definition declares one Agent. An Agent Invocation runs that Agent once. Capabilities attach controlled abilities to the Agent.

server/agents/support.ts
import { gateway } from '@ai-sdk/gateway'
import { defineAgent } from '@vite-hub/agent'
import { workspaceShell } from '@vite-hub/agent/capabilities'

export default defineAgent({
  instructions: 'Answer support questions from the connected workspace.',
  model: gateway('openai/gpt-5.1-mini'),
  capabilities: [
    workspaceShell({ mode: 'read' }),
  ],
})

Agent docs map

PageUse it for
Agent definitionsDefine model, instructions, workspace, and capabilities.
InstructionsCompose durable behavior and capability instruction slots.
InvocationsRun, stream, inspect, and finish one Agent Invocation.
TriggersStart Agent Invocations from server routes, chat, schedules, or product events.
Workspace contextGive an Agent source files without granting unrestricted writes.
CapabilitiesAttach official or custom abilities to an Agent.
EvalsTest agent behavior with repeatable cases.
DevToolsInspect invocations, tools, workspace access, and traces during development.

Agents are not server primitives

Agents can use server primitives, but they do not replace them. The difference is authority.

Server code can call a Runtime Helper directly because the developer wrote that code. A model should only receive model-facing tools, instructions, or runtime context through an explicit Capability.

Copyright © 2026