Skip to content

feat: add Vapi framework support and fix LiveKit missing asyncio import#9

Merged
callumreid merged 2 commits into
mainfrom
feat/vapi-support-and-livekit-asyncio-fix
Apr 2, 2026
Merged

feat: add Vapi framework support and fix LiveKit missing asyncio import#9
callumreid merged 2 commits into
mainfrom
feat/vapi-support-and-livekit-asyncio-fix

Conversation

@callumreid

@callumreid callumreid commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Vapi framework support: The wizard now detects Vapi webhook servers (via vapi-python in deps or assistant-request/end-of-call-report patterns in Python source) and injects framework-specific tracing — including simulation ID extraction from assistantOverrides.variableValues["coval-simulation-id"] and call-ID-keyed caching
  • LiveKit asyncio fix: The LiveKit injection rules now explicitly instruct the LLM to add import asyncio, fixing a NameError at runtime when asyncio.ensure_future() was used without the import
  • server.py entry point: Added server.py to the entry point search list so Vapi projects are detected without relying on the sole-file fallback

Test plan

  • npm run check passes (typecheck + lint + format + 75 tests)
  • Ran wizard against livekit-voice-agent-test-otel-enablement-1import asyncio now present, all hooks correct
  • Ran wizard against pipecat-voice-agent-test-otel-enablement-1coval_tracing.py created, tracing hooks intact
  • Ran wizard against vapi-voice-agent-test-otel-enablement-1 — detected as Vapi (not generic), sim ID extraction wired via assistantOverrides.variableValues, _call_sim_map caching added
  • All three agents' test spans accepted by api.coval.dev
  • Breaking changes: None.
  • Features: Add Vapi framework support (webhook detection, module-level tracing, simulation ID extraction from assistantOverrides.variableValues["coval-simulation-id"], per-call caching keyed by call_id).
  • Fixes: Ensure LiveKit instrumentation rules instruct adding import asyncio to avoid NameError with asyncio.ensure_future().
  • Enhancements: Extend entry-point discovery to include server.py and add Vapi labels to framework constants.
  • Tests: Add Vapi detection and prompt-content expectations to Jest tests.
File Change Type Lines Changed
src/prompts.ts Feature +18/-0
src/tests/detect.test.ts Test +12/-0
src/tests/prompts.test.ts Test +8/-0

- Add 'vapi' as a detected framework alongside pipecat/livekit/generic
- Detect Vapi from dependency manifests (vapi-python) and webhook patterns
  (assistant-request, end-of-call-report) in Python source
- Add Vapi-specific injection rules: simulation ID extraction from
  assistantOverrides.variableValues["coval-simulation-id"], call ID caching,
  and setup_coval_tracing at module level
- Fix LiveKit rules to explicitly require 'import asyncio' — the previous
  rules used asyncio.ensure_future() without the import, causing NameError
  at runtime when a SIP participant connected
- Add server.py to ENTRY_POINT_NAMES for Vapi webhook projects
- Add tests for Vapi detection and prompt rules
@coderabbitai

coderabbitai Bot commented Apr 1, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ceeb018c-c2a8-456c-a418-f986c6c1ded8

📥 Commits

Reviewing files that changed from the base of the PR and between 8842f44 and 66009fb.

📒 Files selected for processing (5)
  • src/__tests__/detect.test.ts
  • src/__tests__/prompts.test.ts
  • src/constants.ts
  • src/detect.ts
  • src/prompts.ts

Walkthrough

Adds VAPI framework support: constants.ts adds FRAMEWORKS.VAPI, a Vapi label, and appends server.py to ENTRY_POINT_NAMES. detect.ts extends detectFramework to recognize VAPI via dependency files (vapi, vapi-python) and Python webhook/handler patterns returning FRAMEWORKS.VAPI. prompts.ts adds VAPI-specific FRAMEWORK_RULES describing tracing setup, simulation ID extraction/caching, and related handler requirements. Tests updated: new detectFramework tests for VAPI and expanded prompt tests to assert VAPI- and LiveKit-specific prompt contents. No exported API signatures were changed.

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed Title follows Conventional Commits format with 'feat:' type and clearly describes the main changes: Vapi framework support and LiveKit asyncio import fix.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/vapi-support-and-livekit-asyncio-fix

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/__tests__/detect.test.ts`:
- Around line 72-76: Add a regression test in src/__tests__/detect.test.ts that
verifies detectFramework does not return 'vapi' when a Python file contains
webhook event tokens like "assistant-request" or "end-of-call-report" but does
not include the literal "vapi"; use the same helpers (makeTempDir, touch) and
assert that detectFramework(dir) is not 'vapi' (or equals the expected non-vapi
result per existing behavior) to cover this failure mode alongside the existing
positive test that detects vapi when the "vapi" token is present.

In `@src/__tests__/prompts.test.ts`:
- Around line 25-30: Update the 'includes vapi-specific rules' test for
buildSystemPrompt('vapi') to assert that the generated prompt forbids
instrumentation and includes call-ID caching guidance: specifically add an
expectation that prompt does NOT contain the symbol 'instrument_session' (or the
exact phrase used to forbid instrumentation) and that it DOES contain the
call-ID cache guidance text (e.g., 'call-ID cache' or the exact guidance string
used by buildSystemPrompt). Keep these checks alongside the existing
expectations for 'assistantOverrides', 'coval-simulation-id', and
'end-of-call-report'.

In `@src/constants.ts`:
- Line 78: The entry-point priority list ENTRY_POINT_NAMES currently causes
findEntryPoint() to pick app.py before server.py and can miss webhook handlers;
update ENTRY_POINT_NAMES to prefer server.py over app.py (e.g., move "server.py"
earlier than "app.py") so findEntryPoint() (the function using that constant)
will pick server.py when both exist; ensure any related comments are updated to
reflect the new priority.

In `@src/detect.ts`:
- Around line 41-42: The current detection in src/detect.ts uses
/vapi.*(webhook|assistant-request|end-of-call-report)/ which only matches when
"vapi" precedes the event names, missing cases where code references the event
names alone; update the check that returns FRAMEWORKS.VAPI to instead test for
any of the Vapi identifiers (e.g. use a regex like
/\b(?:vapi|webhook|assistant-request|end-of-call-report)\b/ or equivalent)
against content so presence of the event names alone will also trigger
FRAMEWORKS.VAPI.

In `@src/prompts.ts`:
- Around line 358-365: The snippet uses call_id and call without showing how
they are obtained, which can produce undefined-variable code; update the webhook
handler to first extract/derive call_id and call from the incoming payload
(e.g., request body/event object) and then run the existing logic that checks
call_id not in _call_sim_map, reads assistantOverrides.variableValues, looks up
"coval-simulation-id", calls set_simulation_id(str(sim_id)) and sets
_call_sim_map[call_id] = str(sim_id); also add defensive guards (ensure call and
call.get exist) so the block only runs when the extracted call_id and call are
present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 97d6f869-83b2-48bc-9d46-fe6c1d81a3b0

📥 Commits

Reviewing files that changed from the base of the PR and between b269264 and 8842f44.

📒 Files selected for processing (5)
  • src/__tests__/detect.test.ts
  • src/__tests__/prompts.test.ts
  • src/constants.ts
  • src/detect.ts
  • src/prompts.ts

Comment thread src/__tests__/detect.test.ts
Comment thread src/__tests__/prompts.test.ts
Comment thread src/constants.ts
Comment thread src/detect.ts
Comment thread src/prompts.ts

@borgesius borgesius left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yer a wizard Harry

Incorporate PR #8's changes (pipecat bot.py priority, OTel dep injection,
sync LiveKit sim ID handler) while keeping Vapi framework support and
server.py entry point addition.

Removed redundant 'import asyncio' instruction from LiveKit rules since
PR #8 switched to synchronous _check_sim_id (no asyncio needed).
@callumreid callumreid merged commit 7f88c6b into main Apr 2, 2026
2 checks passed
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.

2 participants