> ## Documentation Index
> Fetch the complete documentation index at: https://trytilde.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Add an agent in agents/

> Add an agent to a Tilde project: its code, its prompt in prompts/, and its skills in skills/, registered together on every deploy.

Each folder in `agents/` is one agent: your framework code, with its prompts and skills next to it. When you deploy, `tilde deploy` reads the prompts and skills from the code and registers them with the release, so they are versioned with the commit. See [Anatomy of an agent](https://trytilde.ai/docs/anatomy-of-an-agent.md) for how an agent runs.

```text theme={"system"}
agents/support/
  package.json
  src/index.ts                  connects to Tilde, and exports what tilde deploy reads
  src/agent.ts                  the agent, in your framework
  prompts/instructions.md       its instructions
  skills/account-notes/SKILL.md one skill per folder
```

This example uses the Vercel AI SDK. Any [framework](https://trytilde.ai/docs/frameworks/overview.md) works the same way.

## The package

```json agents/support/package.json theme={"system"}
{
  "name": "support-agent",
  "private": true,
  "type": "module",
  "scripts": { "build": "tsc" },
  "dependencies": {
    "@ai-sdk/openai": "^3.0.0",
    "@trytilde/sdk": "^5.2.0",
    "@trytilde/sdk-vercel-ai-node": "^5.2.0",
    "ai": "^6.0.0"
  },
  "devDependencies": { "typescript": "^5.9.0" }
}
```

## Prompt and skills

Keep the instructions in a Markdown file, so reviewers see prompt changes as plain diffs.

```markdown agents/support/prompts/instructions.md theme={"system"}
You are the helpdesk's support agent.
Find the customer with listCustomers, read them with customerOverview,
and record what you learn with setNotes. Reply with sendMessage.
```

A skill is a folder with a `SKILL.md`. The agent sees its name and description, and reads the rest only when it needs it. See [Skills](https://trytilde.ai/docs/skills/overview.md).

```markdown agents/support/skills/account-notes/SKILL.md theme={"system"}
---
name: account-notes
description: How to write customer notes. Use before calling setNotes.
---

Keep the existing notes, and add one dated line at the end, such as
"2026-11-20: asked about SSO."
```

## The code

`agent.ts` defines the agent and handles one invocation. The adapter registers its `instructions` as a versioned [prompt](https://trytilde.ai/docs/prompts/overview.md).

```ts agents/support/src/agent.ts theme={"system"}
import { readFileSync } from "node:fs";
import { createOpenAI } from "@ai-sdk/openai";
import { defineSkills, inference, type AgentContext } from "@trytilde/sdk";
import { convertToAiSdkMessages, tildeAiSdk, tildeCallOptions } from "@trytilde/sdk-vercel-ai-node";
import { ToolLoopAgent, convertToModelMessages, stepCountIs } from "ai";

const instructions = readFileSync(new URL("../prompts/instructions.md", import.meta.url), "utf8");

// Every folder under skills/ that holds a SKILL.md.
export const skills = defineSkills({ dir: new URL("../skills", import.meta.url) });

// The agent's `openai/production` inference connection. The gateway swaps in the real key.
const openai = createOpenAI(inference("openai/production"));

export const agent = new ToolLoopAgent({
  id: "support",
  instructions,
  model: openai.responses("gpt-5-mini"),
  stopWhen: stepCountIs(10),
  ...tildeCallOptions,
});

export async function respond(ctx: AgentContext) {
  const history = await ctx.message.history();
  const messages = await convertToAiSdkMessages({ messages: history.items, context: ctx });
  // tildeAiSdk adds the channel's tools, the agent's tools (the ontology's), and its skills.
  await agent.generate({ messages: await convertToModelMessages(messages), ...tildeAiSdk(ctx) });
}
```

`index.ts` connects to Tilde, and exports the agent and skills so `tilde deploy` can find them.

```ts agents/support/src/index.ts theme={"system"}
import { connectAgent } from "@trytilde/sdk";
import { respond } from "./agent.js";

export { agent, skills } from "./agent.js";

const connection = connectAgent({ run: respond });
for (const signal of ["SIGINT", "SIGTERM"] as const) process.once(signal, () => void connection.close());
```

The agent never calls the ontology directly. It gets `listCustomers`, `customerOverview`, and `setNotes` as tools once you connect it, in the next step.

## Next

[Deploy the project](https://trytilde.ai/docs/project/deploy.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.