# 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 without an API key.
- [Learning path](https://vitehub.dev/docs/agents/get-started): go from the first run to models, tools, and a full app.
- [Build a chat app](https://vitehub.dev/docs/agents/build-a-chat-app): add a model, a streaming route, and a Vue chat UI.

## Define and run

An Agent Definition picks a Driver, the thing that does the work. An Invocation runs the definition 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. For model output, provider Drivers, and streaming, follow [Invocations](https://vitehub.dev/docs/agents/invocations).

## 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 a 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/agents/presets) give full workflows, each with its own setup.

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

Use 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)

The agent cannot use a server feature until you add a tool for it. Built-in tools include web search, memory, and MCP servers.

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

Give it a folder of files from your project or GitHub. You decide if it can only read them 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/agents/presets)

Babysitter fixes pull requests. The Workspace preset answers from your files and links to them. 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)
- [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)
- [Recipes](https://vitehub.dev/raw/docs/agents/support-agent.md)
- [Presets](https://vitehub.dev/raw/docs/agents/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)
