feat: add Vapi framework support and fix LiveKit missing asyncio import#9
Conversation
- 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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
WalkthroughAdds VAPI framework support: constants.ts adds FRAMEWORKS.VAPI, a Vapi label, and appends 🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (5)
src/__tests__/detect.test.tssrc/__tests__/prompts.test.tssrc/constants.tssrc/detect.tssrc/prompts.ts
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).
Summary
vapi-pythonin deps orassistant-request/end-of-call-reportpatterns in Python source) and injects framework-specific tracing — including simulation ID extraction fromassistantOverrides.variableValues["coval-simulation-id"]and call-ID-keyed cachingimport asyncio, fixing aNameErrorat runtime whenasyncio.ensure_future()was used without the importserver.pyto the entry point search list so Vapi projects are detected without relying on the sole-file fallbackTest plan
npm run checkpasses (typecheck + lint + format + 75 tests)livekit-voice-agent-test-otel-enablement-1—import asyncionow present, all hooks correctpipecat-voice-agent-test-otel-enablement-1—coval_tracing.pycreated, tracing hooks intactvapi-voice-agent-test-otel-enablement-1— detected as Vapi (not generic), sim ID extraction wired viaassistantOverrides.variableValues,_call_sim_mapcaching addedapi.coval.dev