Skip to content

Commit ad6962d

Browse files
committed
docs: add learnings guides for non-obvious backend behaviors
Split reference covering tools, assistants, squads, structured outputs, simulations, and webhooks into focused docs under docs/learnings/ so agents can load only the context they need. Updated AGENTS.md and CLAUDE.md to reference the new directory.
1 parent b1b4f0c commit ad6962d

9 files changed

Lines changed: 730 additions & 19 deletions

File tree

AGENTS.md

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@ This project manages **Vapi voice agent configurations** as code. All resources
44

55
**You do NOT need to know how Vapi works internally.** This guide tells you everything you need to author and modify resources.
66

7-
**Prompt quality:** Whenever you create a new assistant or change an existing assistant’s system prompt, read **`docs/Vapi Prompt Optimization Guide.md`** first. It goes deeper on structure, voice constraints, tool usage, and evaluation than the summary in this file.
7+
**Prompt quality:** Whenever you create a new assistant or change an existing assistant’s system prompt, read `**docs/Vapi Prompt Optimization Guide.md`** first. It goes deeper on structure, voice constraints, tool usage, and evaluation than the summary in this file.
88

9-
**Environment-scoped resources:** Resources live in `resources/<env>/` (e.g. `resources/dev/`, `resources/prod/`). Each environment directory is isolated — `push:dev` only touches `resources/dev/`, `push:prod` only touches `resources/prod/`. See **`docs/environment-scoped-resources.md`** for the full promotion workflow and rationale.
9+
**Environment-scoped resources:** Resources live in `resources/<env>/` (e.g. `resources/dev/`, `resources/prod/`). Each environment directory is isolated — `push:dev` only touches `resources/dev/`, `push:prod` only touches `resources/prod/`. See `**docs/environment-scoped-resources.md`** for the full promotion workflow and rationale.
1010

1111
**Template-safe first run:** In a fresh clone, prefer `npm run pull:dev:bootstrap` (or the matching env) to refresh `.vapi-state.<env>.json` and credential mappings without materializing the target org's resources into `resources/<env>/`. `push:<env>` will auto-run the same bootstrap sync when it detects empty or stale state for the resources being applied.
1212

13+
**Gotchas & best practices:** Before configuring tools, assistants, squads, structured outputs, or simulations, consult the relevant file in `**docs/learnings/`**. Each file documents non-obvious backend behaviors, silent defaults, and common foot-guns for a specific resource type — things the API reference doesn't cover. See `**docs/learnings/README.md`** for the index.
14+
1315
---
1416

1517
## Quick Reference
1618

19+
1720
| I want to... | What to do |
1821
| ----------------------------------- | ----------------------------------------------------------------------------- |
1922
| Edit an assistant's system prompt | Edit the markdown body in `resources/<env>/assistants/<name>.md` |
@@ -31,6 +34,7 @@ This project manages **Vapi voice agent configurations** as code. All resources
3134
| Push only one file | `npm run push:dev resources/dev/assistants/my-agent.md` |
3235
| Test a call | `npm run call:dev -- -a <assistant-name>` |
3336

37+
3438
---
3539

3640
## Project Structure
@@ -39,7 +43,15 @@ This project manages **Vapi voice agent configurations** as code. All resources
3943
docs/
4044
├── Vapi Prompt Optimization Guide.md # In-depth prompt authoring
4145
├── environment-scoped-resources.md # Environment isolation & promotion workflow
42-
└── changelog.md # Template for tracking per-customer config changes
46+
├── changelog.md # Template for tracking per-customer config changes
47+
└── learnings/ # Non-obvious backend behaviors & foot-guns
48+
├── README.md # Index of all learning docs
49+
├── tools.md # apiRequest, function, transferCall, endCall, handoff, code
50+
├── assistants.md # Model, voice, transcriber, hooks, endpointing, analysis
51+
├── squads.md # Name uniqueness, overrides, handoff context
52+
├── structured-outputs.md # Schema types, assistant_ids, extraction models
53+
├── simulations.md # Personalities, evaluations, chat-mode gotcha
54+
└── webhooks.md # Server messages, timeouts, credentials, payloads
4355
4456
resources/
4557
├── dev/ # Dev environment resources (push:dev reads here)
@@ -119,6 +131,7 @@ You are a virtual assistant for the business you represent...
119131

120132
#### Key Assistant Settings
121133

134+
122135
| Setting | Purpose | Common Values |
123136
| ---------------------------- | -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
124137
| `name` | Display name in Vapi dashboard | Any string |
@@ -145,6 +158,7 @@ You are a virtual assistant for the business you represent...
145158
| `observabilityPlan` | Logging/monitoring | `{ provider: "langfuse", tags: [...] }` |
146159
| `compliancePlan` | HIPAA/PCI compliance | `{ hipaaEnabled: false, pciEnabled: false }` |
147160

161+
148162
#### Voice Configuration
149163

150164
```yaml
@@ -363,13 +377,15 @@ function:
363377

364378
#### Tool Message Types
365379

380+
366381
| Type | Purpose | Key Properties |
367382
| -------------------------- | --------------------------- | ------------------------------------------------------- |
368383
| `request-start` | Said when tool is called | `content`, `blocking` (pause speech until tool returns) |
369384
| `request-response-delayed` | Said if tool takes too long | `content`, `timingMilliseconds` |
370385
| `request-complete` | Said when tool returns | `content` |
371386
| `request-failed` | Said when tool errors | `content` |
372387

388+
373389
---
374390

375391
### Structured Outputs (`.yml`)
@@ -450,7 +466,7 @@ schema:
450466
- `assistant_ids` uses **Vapi UUIDs** (not local filenames) — these are the IDs of assistants this output applies to
451467
- `target: messages` means the LLM analyzes the full message history
452468
- `type: ai` means an LLM generates the output (vs. `type: code` for programmatic)
453-
- **`schema.type` must be a simple string** (e.g. `type: string`, `type: boolean`, `type: object`). Do NOT use a YAML array like `type: [string, "null"]` — the Vapi dashboard calls `.toLowerCase()` on this field and will crash with `TypeError: .toLowerCase is not a function` if it receives an array. For nullable values, express nullability in the `description` instead (e.g. "Return null if no follow-up is needed")
469+
- `**schema.type` must be a simple string** (e.g. `type: string`, `type: boolean`, `type: object`). Do NOT use a YAML array like `type: [string, "null"]` — the Vapi dashboard calls `.toLowerCase()` on this field and will crash with `TypeError: .toLowerCase is not a function` if it receives an array. For nullable values, express nullability in the `description` instead (e.g. "Return null if no follow-up is needed")
454470

455471
---
456472

@@ -607,6 +623,7 @@ simulationIds:
607623

608624
Resources reference each other by **filename without extension**:
609625

626+
610627
| From | Field | References | Example |
611628
| ------------- | ------------------------------------ | ----------------------- | ----------------------------------------- |
612629
| Assistant | `model.toolIds[]` | Tool files | `- end-call-tool` |
@@ -617,6 +634,7 @@ Resources reference each other by **filename without extension**:
617634
| Simulation | `scenarioId` | Scenario files | `scenarioId: happy-path-booking-a0000002` |
618635
| Suite | `simulationIds[]` | Simulation test files | `- booking-test-1-a0000001` |
619636

637+
620638
The gitops engine resolves these local filenames to Vapi UUIDs automatically during push.
621639

622640
---
@@ -625,7 +643,7 @@ The gitops engine resolves these local filenames to Vapi UUIDs automatically dur
625643

626644
The markdown body of an assistant `.md` file is the system prompt — the core instructions that define how the AI behaves on a call. This is the most important part to get right.
627645

628-
**Before drafting or changing prompts:** work through **`docs/Vapi Prompt Optimization Guide.md`** so structure, guardrails, and voice-specific habits stay consistent across agents.
646+
**Before drafting or changing prompts:** work through `**docs/Vapi Prompt Optimization Guide.md`** so structure, guardrails, and voice-specific habits stay consistent across agents.
629647

630648
### Recommended Structure
631649

@@ -728,26 +746,28 @@ Replace `dev` with `prod` for production environment.
728746

729747
For the **complete schema** of all available properties on each resource type, consult the Vapi API documentation:
730748

731-
| Resource | API Docs |
732-
| ------------------ | ----------------------------------------------------------------------------------------- |
733-
| Assistants | https://docs.vapi.ai/api-reference/assistants/create |
734-
| Tools | https://docs.vapi.ai/api-reference/tools/create |
735-
| Squads | https://docs.vapi.ai/api-reference/squads/create |
736-
| Structured Outputs | https://docs.vapi.ai/api-reference/structured-outputs/structured-output-controller-create |
737-
| Simulations | https://docs.vapi.ai/api-reference/simulations |
749+
750+
| Resource | API Docs |
751+
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
752+
| Assistants | [https://docs.vapi.ai/api-reference/assistants/create](https://docs.vapi.ai/api-reference/assistants/create) |
753+
| Tools | [https://docs.vapi.ai/api-reference/tools/create](https://docs.vapi.ai/api-reference/tools/create) |
754+
| Squads | [https://docs.vapi.ai/api-reference/squads/create](https://docs.vapi.ai/api-reference/squads/create) |
755+
| Structured Outputs | [https://docs.vapi.ai/api-reference/structured-outputs/structured-output-controller-create](https://docs.vapi.ai/api-reference/structured-outputs/structured-output-controller-create) |
756+
| Simulations | [https://docs.vapi.ai/api-reference/simulations](https://docs.vapi.ai/api-reference/simulations) |
757+
738758

739759
**For voice/model/transcriber provider options:**
740760

741-
- Voice providers: https://docs.vapi.ai/providers/voice
742-
- Model providers: https://docs.vapi.ai/providers/model
743-
- Transcriber providers: https://docs.vapi.ai/providers/transcriber
761+
- Voice providers: [https://docs.vapi.ai/providers/voice](https://docs.vapi.ai/providers/voice)
762+
- Model providers: [https://docs.vapi.ai/providers/model](https://docs.vapi.ai/providers/model)
763+
- Transcriber providers: [https://docs.vapi.ai/providers/transcriber](https://docs.vapi.ai/providers/transcriber)
744764

745765
**For feature-specific documentation:**
746766

747-
- Hooks: https://docs.vapi.ai/assistants/hooks
748-
- Tools: https://docs.vapi.ai/tools
749-
- Squads: https://docs.vapi.ai/squads
750-
- Workflows: https://docs.vapi.ai/workflows
767+
- Hooks: [https://docs.vapi.ai/assistants/hooks](https://docs.vapi.ai/assistants/hooks)
768+
- Tools: [https://docs.vapi.ai/tools](https://docs.vapi.ai/tools)
769+
- Squads: [https://docs.vapi.ai/squads](https://docs.vapi.ai/squads)
770+
- Workflows: [https://docs.vapi.ai/workflows](https://docs.vapi.ai/workflows)
751771

752772
> **Tip:** The Vapi MCP server and API reference pages provide full JSON schemas with all available fields, enums, and defaults. Use them to discover settings not covered in this guide.
753773
@@ -808,3 +828,4 @@ If you need a local mock server to validate webhook payloads or message delivery
808828
- Assume decryption only works when the corresponding private keys are already available in your zsh environment.
809829
- For local webhook validation, prioritize core `serverMessages` event types such as `speech-update`, `status-update`, and `end-of-call-report`.
810830
- To test callbacks from Vapi into your local machine, expose the mock server with a tunnel like `ngrok` and use that public HTTPS URL in `assistant.server.url`.
831+

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ When both files exist, follow both. If guidance overlaps, treat `AGENTS.md` as t
1111

1212
1. Read `AGENTS.md` first.
1313
2. Then read this file (`CLAUDE.md`) for additional policy constraints.
14+
3. When configuring any resource (tools, assistants, squads, structured outputs, simulations), consult the relevant file in `docs/learnings/` for non-obvious backend behaviors and silent defaults that can cause unexpected runtime results. See `docs/learnings/README.md` for the index.

docs/learnings/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Gotchas & Best Practices
2+
3+
Non-obvious behaviors, silent defaults, and foot-guns in the Vapi backend that affect how your YAML/JSON resources behave at runtime. This is a companion to the API reference — it covers what the docs _don't_ tell you.
4+
5+
Each file in this directory covers a specific resource type so you can load only the context you need:
6+
7+
| File | What it covers |
8+
|------|----------------|
9+
| [tools.md](tools.md) | apiRequest, function, transferCall, endCall, handoff, code tools; tool messages; strict mode |
10+
| [assistants.md](assistants.md) | Model defaults, voice, transcriber, firstMessage, hooks, idle messages, endpointing, interruption, analysis, artifacts, background sound, server messages, HIPAA, tool resolution |
11+
| [squads.md](squads.md) | Name uniqueness, tools:append, assistantDestinations, handoff context, override merge order |
12+
| [structured-outputs.md](structured-outputs.md) | Schema type gotchas, assistant_ids, default models, target modes |
13+
| [simulations.md](simulations.md) | Personalities, evaluation comparators, chat-mode gotcha, missing references |
14+
| [webhooks.md](webhooks.md) | Default server messages, timeouts, unreachable servers, credential resolution, payload shape |
15+
16+
**When to read these:** Before creating or modifying any resource file in `resources/<env>/`. These gotchas document behavior that the API reference and dashboard don't make obvious.

0 commit comments

Comments
 (0)