Skip to content

fix(vapi): bisect 'Couldn't get assistant' — strip recent assistant config additions #32

@ByteStreams-AI

Description

@ByteStreams-AI

Symptom

Calls hit "Couldn't get assistant" from Vapi. Reproduced May 5 2026 multiple times.

What we know

Root cause hypothesis

Vapi tightened validation on one of these fields between May 4 (PR #27 deploy worked) and May 5 (post-PR #30 deploy fails):

  • `endCallFunctionEnabled: true`
  • `endCallPhrases: [...]`
  • per-tool `messages` array — `request-response-delayed` filler ("Just a second.")
  • per-tool `messages` array on `end_call` — `request-complete` with `endCallAfterSpoken: true`

Proposed approach

Bisect by stripping all four to a known-good baseline. If the call connects, add fields back one at a time (separate Issues per restoration) to identify which one broke.

File to edit

`supabase/functions/vapi_call_start/index.ts` — `handleAssistantRequest` function.

Specific edits

1. Strip from the assistant response object:

  • Remove `endCallFunctionEnabled: true`
  • Remove `endCallPhrases`

2. Strip the `endCallPhrases` array declaration above (the 15-phrase list with comment).

3. Strip per-tool `messages` from `wrappedTools`:

  • Remove the special `if (t.name === 'end_call')` branch with `request-complete` + `endCallAfterSpoken: true`
  • Remove `messages: toolDelayMessages` from the default branch
  • Strip the `toolDelayMessages` declaration above

After stripping, each wrapped tool should be just:
```ts
{
type: 'function' as const,
function: { name: t.name, description: t.description, parameters: t.parameters },
server: { url: dispatcherUrl, timeoutSeconds: 20 },
}
```

4. Update integration tests in packages/shared/test/db/voice.test.ts:

Expected diff scope

  • One file: `vapi_call_start/index.ts` — ~50 line removal
  • Maybe one test file: `voice.test.ts` — 1-2 assertion removals
  • 299/299 unit tests should still pass

Test plan

  • `pnpm ci:fast` green
  • Deploy to cloud
  • Place a test call to +16296001047
  • If the call connects: breaking field is one of the four. File restoration Issues for each, individually.
  • If still fails: look further upstream — possibly model name (`gpt-4o-mini`), prompt size, or tool wrap shape.

Risk + UX regression if this lands

  • Slow tool calls produce silence instead of "Just a second" filler
  • Calls may not auto-hang-up after goodbye if the LLM forgets `end_call`
  • All recoverable by re-adding the offending field with caution

What is NOT touched

  • All prompt logic (cart verification, customer name, phone confirm, modifier discipline, agent_name)
  • All Edge Functions (`vapi_get_cart_state`, `vapi_cancel_order`)
  • All tool schemas (`get_cart_state`, `cancel_order`)
  • All cart integrity work, three-gate SMS dispatch
  • Vapi/Telnyx/Stripe/Supabase external configurations

Suggested branch + commits

```
git checkout -b fix/m11-strip-assistant-config-bisect

edits per "Specific edits" above

pnpm ci:fast
git diff # review
git commit -am "fix(vapi): bisect — strip endCall* and per-tool messages from assistant config"
git push -u origin fix/m11-strip-assistant-config-bisect
gh pr create --title "fix(vapi): strip recent assistant config additions to isolate Vapi validator regression"
```

Rollback

If the strip breaks something else: `git revert` and we're back to current main. The strip touches only one file's response shape, no schema or external config.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions