Skip to content

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

Merged
dhruva-vapi merged 11 commits into
feat/blocksfrom
examples/nhs-shared-squads
Nov 21, 2026
Merged

dhruva-vapi merged 11 commits into
feat/blocksfrom
examples/nhs-shared-squads

Conversation

@dhruva-vapi

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

Copy link
Copy Markdown
Contributor

Summary

examples/nhs-shared-squads/ is a worked version of the PRISM-2684 setup: two shared assistants and one shared handoff tool, used by two practice squads that differ only in their membersOverrides. Adding another practice means adding one more squad file.

# squads/nhs-test-practice-a.yml (practice-b has the same shape with its own values)
members:
  - assistantId: nhs-test-reception
  - assistantId: nhs-test-appointments
membersOverrides:
  'tools:append':
    - type: transferCall          # per-practice, literal E.164 numbers
      destinations:
        - { type: number, number: '+442079460101' }   # urgent
        - { type: number, number: '+442079460102' }   # admin
  variableValues:
    practice_name: Example Willow GP Practice
    practice_mailbox: willow.demo@example.nhs.uk
    opening_hours: Monday to Friday, 08:00 to 18:30 UK local time
    urgent_handover_number: '+442079460101'   # for the prompt text; keep in sync with the tool
    admin_handover_number: '+442079460102'
  • Shared content: the practice context and handover rules are prompt blocks (templates/blocks/nhs-test-{practice,handover}.md, from feat(blocks): shared prompt and config blocks, with a sync command #94). The model and voice are one config block, nhs-test-assistant.yml.
  • Literal transfer numbers: each squad's transfer tool is inline in its tools:append, with literal numbers. The API rejects Liquid in destinations[].number (POST /tool returns 400, even with numberE164CheckEnabled: false), so a shared tool using {{urgent_handover_number}} isn't possible. feat(validate): catch undefined squad variables and Liquid transfer numbers #99 adds a transfer-number-liquid validate error for this. The handover numbers stay in variableValues only so the prompts can say them.
  • Fake numbers: handover numbers come from the Ofcom drama range, so they don't connect. The demo prompts tell the assistant not to transfer, and assistant-to-assistant handoff still works.
  • Missing-variable check: this example shows feat(validate): catch undefined squad variables and Liquid transfer numbers #99's variable-undefined rule. npm run validate -- nhs-test --strict is clean. Removing practice_mailbox from practice-b warns for practice-b's two members only.
  • Live run: this example was pushed to a real org with a file-scoped push. It created 2 assistants, 1 tool and 2 squads, and nothing already in the org changed. GET confirmed both squads use the same two assistant IDs with different values. No call has been placed yet; that is the reviewer's live-call step.

Based on feat/blocks (#94, which now includes #99). No engine code changed.

dhruva-vapi and others added 2 commits November 20, 2026 23:20
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

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

dhruva-vapi and others added 3 commits November 20, 2026 23:27
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 and others added 5 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>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
devin-ai-integration Bot changed the base branch from feat/validate-undefined-variables to feat/blocks November 21, 2026 00:27
@dhruva-vapi
dhruva-vapi merged commit bd98584 into feat/blocks Nov 21, 2026
6 checks passed
devin-ai-integration Bot added a commit that referenced this pull request Nov 21, 2026
* 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>
devin-ai-integration Bot added a commit that referenced this pull request Nov 24, 2026
* 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>
devin-ai-integration Bot added a commit that referenced this pull request Nov 24, 2026
* 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>
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