# Agents

Define an AI agent in one file, give it files and tools, and reach it from chat, Slack, or GitHub.

Hosts: Node, Docker, Cloudflare, Vercel, Netlify, Deno.

Built-in channels: Web chat, HTTP, Slack, Discord, Telegram, Teams, GitHub, GitLab, Forgejo, Gmail.

:hero-figure{name="agents"}

## Start here

- [First Agent](https://vitehub.dev/docs/getting-started/first-agent): run an Agent with no API key.
- [Learning path](https://vitehub.dev/docs/agents/get-started): go from your first run to models, tools, and a full app.
- [Build a chat app](https://vitehub.dev/docs/agents/build-a-chat-app): connect a model, a streaming route, and a Vue chat UI.

For a single model call without tools, such as a summary or fields read from text, you do not need an Agent. Call [`ask(prompt, { model, schema })`](https://vitehub.dev/docs/gateways/server-api#get-typed-data-from-a-model) from AI Gateways to get data checked against your schema.

## Define and run

An Agent Definition picks a Driver to do the work, and an Invocation runs it with one input. This example needs no model or credentials:

```ts
import { defineAgent, runAgent } from 'vite-hub/agent'

const greeting = defineAgent({
  runtime: false,
  driver: {
    run({ prompt }) {
      const name = typeof prompt === 'string' ? prompt : 'friend'
      return { text: `Hello, ${name}!` }
    },
  },
})

const [error, result] = await runAgent(greeting, { prompt: 'Ada' })
if (error) throw error
console.log(result.text) // 'Hello, Ada!'
```

`runAgent()` returns an `[error, result]` tuple. See [Invocations](https://vitehub.dev/docs/agents/invocations) for model output, provider Drivers, and streaming.

## Learn in order

1. [Define an Agent](https://vitehub.dev/docs/agents/agent-definitions) and [choose its Driver](https://vitehub.dev/docs/agents/agent-drivers).
2. [Run or stream an Invocation](https://vitehub.dev/docs/agents/invocations).
3. [Write instructions](https://vitehub.dev/docs/agents/instructions) and [attach tools through Capabilities](https://vitehub.dev/docs/agents/capabilities).
4. [Select Chat History](https://vitehub.dev/docs/agents/chat-history-sessions) and [add Workspace context](https://vitehub.dev/docs/agents/workspace-context).
5. [Connect a Channel](https://vitehub.dev/docs/agents/channels) for messages from another service or web chat.
6. [Inspect events](https://vitehub.dev/docs/agents/observability), [test contracts](https://vitehub.dev/docs/agents/testing), and [evaluate model behavior](https://vitehub.dev/docs/agents/evals).

Then share configuration with [presets and inheritance](https://vitehub.dev/docs/agents/agent-presets) and keep run records with [Invocation storage](https://vitehub.dev/docs/agents/invocation-storage). [Ready-made presets](https://vitehub.dev/docs/presets) give full workflows, each with its own setup.

### [Choose what does the work](https://vitehub.dev/docs/agents/agent-drivers)

Run an AI model, Codex, Claude Code, or your own function. Your routes call the Agent the same way.

### [Give it only the tools you choose](https://vitehub.dev/docs/agents/capabilities)

An Agent cannot use a server feature until you add a tool for it. Built-in tools cover web search, memory, and MCP servers.

### [Let it read your files](https://vitehub.dev/docs/agents/workspace-context)

Give it a folder from your project or GitHub. You choose whether the Agent can only read or also write.

### [Talk to it where people already are](https://vitehub.dev/docs/agents/channels)

Connect web chat, Slack, Discord, Telegram, Teams, GitHub, or an HTTP route.

### [Call it like a function](https://vitehub.dev/docs/agents/invocations#run-an-agent)

`runAgent()` runs the Agent and returns its result. The ViteHub Console shows what happened in each run.

### [Start from a ready-made agent](https://vitehub.dev/docs/presets)

Babysitter fixes pull requests, and the Workspace preset answers from your files with links. Add your settings and run it.

<!-- vitehub-docs:section-links -->
## In this section

- Start
  - [Overview](https://vitehub.dev/raw/docs/agents.md) (this page)
  - [Learning path](https://vitehub.dev/raw/docs/agents/get-started.md)
  - [Agent harness](https://vitehub.dev/raw/docs/agents/harness.md)
  - [Build a chat app](https://vitehub.dev/raw/docs/agents/build-a-chat-app.md)
  - [Build a support Agent](https://vitehub.dev/raw/docs/agents/support-agent.md)
- [Define and run](https://vitehub.dev/raw/docs/agents/agent-definitions.md)
- [Instructions and tools](https://vitehub.dev/raw/docs/agents/instructions.md)
- [History and context](https://vitehub.dev/raw/docs/agents/chat-history-sessions.md)
- [Channels](https://vitehub.dev/raw/docs/agents/channels.md)
- [Inspect and evaluate](https://vitehub.dev/raw/docs/agents/observability.md)
- [Advanced](https://vitehub.dev/raw/docs/agents/agent-presets.md)
- [Capabilities](https://vitehub.dev/raw/docs/agents/capabilities/access.md)

Next: [AGENT_R0001](https://vitehub.dev/raw/docs/agents/diagnostics/agent_r0001.md)

All pages: [llms.txt](https://vitehub.dev/llms.txt)
