Skip to content

feat(validate): catch undefined squad variables and Liquid transfer numbers - #99

Merged
dhruva-vapi merged 4 commits into
feat/blocksfrom
feat/validate-undefined-variables
Nov 21, 2026
Merged

dhruva-vapi merged 4 commits into
feat/blocksfrom
feat/validate-undefined-variables

Conversation

@dhruva-vapi

@dhruva-vapi dhruva-vapi commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two offline validate rules for sharing one assistant set across many practice squads (PRISM-2684). Stacked on #94, so prompt blocks are expanded before the checks run.

variable-undefined (warn; blocking with --strict)

On a live call, Vapi leaves an undefined Liquid variable in the text as the literal {{name}} (PRISM-2672). A squad that forgets practice_mailbox would read {{practice_mailbox}} to a caller. For each squad member, the rule checks the effective assistant (base merged with member assistantOverrides, then squad membersOverrides):

  • Texts checked: system prompt/messages, firstMessage, voicemailMessage, endCallMessage, and string fields of attached tools (model.toolIds, inline model.tools, tools:append, transfer destinations). Tool code is not checked.
  • Treated as defined:
    • member and squad variableValues
    • Vapi built-ins: customer, phoneNumber, transport, call, now, currentDateTime, date, time, year, month, day, from vapi assistantDefaultOverridesBuild.ts and variableUtil.ts
    • names any squad tool's variableExtractionPlan sets
    • Liquid assign/capture/for locals
  • Ignored: raw/comment blocks, filter names, and dotted paths, which are checked by their root name.
  • Output: one finding per squad member, listing the missing names.
  • Not checked: standalone assistants, which get their values at call time.

It is a warning, not an error, because values can also come at call time (API assistantOverrides, phone-number overrides), which files can't see. Only this rule is promoted by --strict; other warnings behave as before.

transfer-number-liquid (error)

This was found on the live run: POST /tool returns 400 when a transferCall destinations[].number holds {{urgent_handover_number}}. Setting numberE164CheckEnabled: false doesn't help, because the API still requires ^\+?[a-zA-Z0-9]+$ (vapi transferCallTool.types.ts). The rule flags {{ or {% in transfer numbers wherever the tool is defined: standalone tools, inline model.tools, and member/squad tools:append. Its message points to a per-practice literal number in the squad's membersOverrides["tools:append"] (see #100).

Tests: tests/validate-variables.test.ts (12 cases, including two squads sharing one assistant where only one is missing a value) and tests/validate-transfer-numbers.test.ts (8 cases). Results: npm test 733 pass / 0 fail, tsc clean, biome clean.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access that start with 'Devin'.

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Devin Review

🟢 Devin Review found nothing to fix · View findings

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration devin-ai-integration Bot changed the title feat(validate): warn on undefined squad variables feat(validate): catch undefined squad variables and Liquid transfer numbers Nov 20, 2026
dhruva-vapi and others added 2 commits November 21, 2026 00:18
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@dhruva-vapi
dhruva-vapi merged commit be939df into feat/blocks Nov 21, 2026
6 checks passed
devin-ai-integration Bot added a commit that referenced this pull request Nov 21, 2026
…umbers (#99)

* feat(validate): warn on undefined squad variables

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(validate): reject Liquid transfer destination numbers

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs: explain squad variable and transfer number validation

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs: link NHS example across stacked PR branches

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration Bot added a commit that referenced this pull request Nov 24, 2026
…umbers (#99)

* feat(validate): warn on undefined squad variables

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(validate): reject Liquid transfer destination numbers

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs: explain squad variable and transfer number validation

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs: link NHS example across stacked PR branches

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration Bot added a commit that referenced this pull request Nov 24, 2026
…umbers (#99)

* feat(validate): warn on undefined squad variables

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(validate): reject Liquid transfer destination numbers

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs: explain squad variable and transfer number validation

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs: link NHS example across stacked PR branches

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
dhruva-vapi added a commit that referenced this pull request Nov 24, 2026
)

* feat(blocks): share prompt text and config between resources

A system prompt can include a Markdown block with a line that says only
"@include <name>", and any mapping can include a YAML block with a
"$include" key, where the file's own keys win. Blocks are looked up in
resources/<org>/templates/ first, then in templates/ at the repository
root, so an org can replace or extend a shared block. The loader expands
them, so validate, push, PR checks and drift hashes all see the finished
resource. Liquid inside a block is passed through untouched.

Pull never writes a file that uses blocks. It used to rewrite a file
whenever the dashboard matched it, was ahead of it, or under --force and
--resolve=theirs, and each of those would replace a marker with a copy of
the block. It now leaves the file as written and saves the dashboard
version beside it when the two differ.

validate warns about YAML merge keys and Liquid include/render/layout tags,
which the engine and Vapi drop silently.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* feat(blocks): sync a block edit to every resource that uses it

A block edit changes what many resources send to Vapi without changing
their files, so nothing in git said which resources still ran old text.

Push now records the block content each resource went up with in
resources/<org>/.vapi-blocks.json. "npm run sync-blocks" lists, across
every org, the resources whose blocks changed since they were last pushed,
and with --apply deploys them through apply, so the drift check still
refuses a resource that was edited in the dashboard.

Promotion plans those resources as "sync" entries for the destination org,
the promotion workflow runs on templates/**, and a shared block edit
selects every PR check.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* docs(blocks): guide, worked example and the corrections it needs

Adds docs/guides/blocks.md and examples/blocks/, two clinics that share a
red-flags prompt block and a voice config block, one with its own version
of the block. The examples test now copies an example's templates/ folder,
so the example is validated and the guide's snippets are checked against
its files.

Also corrects two statements the feature depends on: YAML merge keys are
not processed by the engine, and an undefined Liquid variable is left in
the prompt as written, not replaced with an empty string.

Logs the pull behaviour this replaces as improvements entry 39, and a
drift-check gap found while testing, in orgs with no credentials, as
entry 40.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* refactor(blocks): keep the blocks record in state/<org>/

Push writes the record, so it belongs with the rest of the engine's files.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix(blocks): keep the blocks record where the org's commit step stages it

An org whose state is still in the layout from before state/ gets its
record at resources/<org>/.vapi-blocks.json. A commit step written for that
layout stages resources/, so the record is committed, and a promotion run
with nothing to promote no longer plans a sync for every resource that uses
a block. An org whose state is in state/<org>/ keeps state/<org>/blocks.json.
npm run migrate moves the record with the state file and the pin.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* test: the blocks record is not a local edit to pull

In the older layout a push that uses blocks rewrites
resources/<org>/.vapi-blocks.json, and until that is committed git shows it
as modified. The record is on the list migrate moves, so pull leaves it out
of what it counts as a person's edits. This pins it with a pull in a fresh
clone.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix(blocks): sync-blocks takes its directory from src/base-dir.ts

sync-blocks worked out the repository's directory for itself, the one
module that still did. It would have worked in the repository while every
other module worked in a test's temporary directory.
tests/base-dir.test.ts names the line.

The blocks tests import the engine sandbox first, as every engine test
file does.

The test that runs sync-blocks --apply gives that one call 240 seconds.
It starts four commands in a row and took 72 seconds on a slow machine
beside the rest of the suite. cliRun takes the limit as a parameter and
keeps 60 seconds for every other call.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* feat(validate): catch undefined squad variables and Liquid transfer numbers (#99)

* feat(validate): warn on undefined squad variables

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(validate): reject Liquid transfer destination numbers

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs: explain squad variable and transfer number validation

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs: link NHS example across stacked PR branches

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs(examples): two NHS practice squads sharing one assistant set (#100)

* feat(validate): warn on undefined squad variables

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs(examples): add shared NHS practice squads

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(examples): inline practice-specific transfer destinations

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(validate): reject Liquid transfer destination numbers

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs: explain squad variable and transfer number validation

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs: add shared practice quick reference

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs: link NHS example across stacked PR branches

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix: integrate blocks with adoption folder hashes and strict preflight

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Dhruva Reddy <dhruva@vapi.ai>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: Dhruva Reddy <264116857+dhruva-vapi@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant