Repository navigation
Execute control-flow tool actions, and take the cold start off the first turn - #10
Merged
My-CMDhub merged 2 commits intoOct 7, 2026
Merged
Conversation
The dispatcher answers hang_up_call and transfer_to_staff with an `action` field, but the cascaded tool loop only serialized the result back to the LLM and never read it. The model therefore *narrated* both actions while nothing performed them: it said goodbye and left the line open, and promised a transfer that never happened. Verified live — hang_up_call fired 3 times on one call (11:13:00, 11:15:33, 11:15:41 AEST) and the leg only ended when the caller hung up at 566s. - read `action` after dispatcher.execute - terminate via Twilio REST Status=completed, idempotent (the model retries a tool that produces no observable effect) - transfer via a TwiML <Dial> update with a redirect back to the AI on no-answer - both fire after the turn's audio has drained, so the farewell and the handoff line are heard first; a barge-in during the farewell aborts the hangup
First call after a dyno boot reached "Call context ready" 4,316ms after the Twilio stream started; the second call on the same dyno took 2ms. Whoever calls first pays the difference, and voice_settings (voice, TTS model, Flux turn thresholds) are not applied until it clears, so the opening turn also ran on Deepgram's defaults rather than the tenant's configuration. Two causes, both removed: - Tenant rows are keyed by an Appwrite document id, not by their slug, so the primary `GET .../documents/coalcreek` always 404'd before the slug query found the row — ~920ms of pure waste per cache miss, logged as a success. Slug query is now primary; document-id lookup stays as fallback. - openai and the dispatcher chain were imported inside `_build_call_context()`, so the first call paid a blocking cold import on the event loop. Startup now warms those imports and pre-fetches the tenant config into its 5-minute cache. Warm-up failures are logged and swallowed — a cold first call is slow, not broken.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The dispatcher answers hang_up_call and transfer_to_staff with an
actionfield, but the cascaded tool loop only serialized the resultback to the LLM and never read it. The model therefore narrated both
actions while nothing performed them: it said goodbye and left the line
open, and promised a transfer that never happened.
Verified live — hang_up_call fired 3 times on one call (11:13:00,
11:15:33, 11:15:41 AEST) and the leg only ended when the caller hung up
at 566s.
actionafter dispatcher.executeretries a tool that produces no observable effect)
no-answer
handoff line are heard first; a barge-in during the farewell aborts
the hangup
Second commit —
perf(voice): remove first-call cold start from the voice hot path:First call after a dyno boot reached "Call context ready" 4,316ms after the
Twilio stream started; the second call on the same dyno took 2ms. Whoever
calls first pays the difference, and voice_settings (voice, TTS model, Flux
turn thresholds) are not applied until it clears, so the opening turn also
ran on Deepgram's defaults rather than the tenant's configuration.
Two causes, both removed:
the primary
GET .../documents/coalcreekalways 404'd before the slugquery found the row — ~920ms of pure waste per cache miss, logged as a
success. Slug query is now primary; document-id lookup stays as fallback.
_build_call_context(), so the first call paid a blocking cold import onthe event loop. Startup now warms those imports and pre-fetches the tenant
config into its 5-minute cache.
Warm-up failures are logged and swallowed — a cold first call is slow, not
broken.