← All Labs Conversational Voice Dual-brain Gemini Live + DurableAgent
Conversational Voice · Built

Dual-brain Gemini Live + DurableAgent

Fast S2S Talker (gemini-3.8-live protocol) answers chitchat directly, delegates tasks via NON_BLOCKING tool calls while speaking fillers, persists sessionResumption handles across GoAway reconnects, and aborts both brains on barge-in.

Built Needs: streaming, tool-calling Smoke: pnpm exec tsx examples/31-voice-live-dual-brain/run.ts --smoke Run: pnpm exec tsx examples/31-voice-live-dual-brain/run.ts Source: examples/31-voice-live-dual-brain

Mechanism: gemini-3.8-live (BidiGenerateContent WebSocket) acts as the acoustic Fast Talker, while DurableAgent acts as the background Durable Thinker invoked through NON_BLOCKING function declarations (delegate_to_durable_agent, abort_durable_agent). sessionResumptionUpdate.newHandle is persisted in VoiceSessionDoc inside agent.sqlite so goAway resets reconnect transparently.

Dual-brain Gemini Live + DurableAgent

zsh
pnpm exec tsx examples/31-voice-live-dual-brain/run.ts          # :7493 + /shell/ with custom:voice-dual-brain
pnpm exec tsx examples/31-voice-live-dual-brain/run.ts --smoke  # offline verification, exit 0

# Live Gemini 3.8 Live + DurableAgent (requires GEMINI_API_KEY in .env)
dotenvx run -- pnpm exec tsx examples/31-voice-live-dual-brain/run.ts \
  --live --model google:gemini-4-hydrogen

Open http://127.0.0.1:7493/shell/ to inspect the two-lane Voice: Dual-Brain Live panel (voice-dual-brain.js) alongside the shared Chat ledger.

Checks

CheckWhat it proves
talker-streams-audio-and-transcriptsChitchat streams 24 kHz PCM audio and transcripts directly from the Talker without waking the Durable Thinker.
non-blocking-delegation-with-fillerTask prompts emit a NON_BLOCKING delegate_to_durable_agent call and speak a conversational filler before DurableAgent finishes, then speak the grounded tool result.
session-resumption-persists-across-goawaysessionResumptionUpdate stores the handle in VoiceSessionDoc, and simulate_goaway reconnects carrying that exact handle.
barge-in-interrupts-both-brainsSending barge_in while the Thinker is held interrupts the Talker, calls conv.abort(), and increments VoiceSessionDoc.bargeIns.
substrate-component-served/shell/manifest.json includes custom:voice-dual-brain and /shell/custom/voice-dual-brain.js returns 200.

Break it

In examples/31-voice-live-dual-brain/run.ts, stop writing d.resumptionHandle = handle inside onResumptionHandle. On simulate_goaway, reconnected.event.resumedFrom becomes null instead of the saved handle, and session-resumption-persists-across-goaway fails.

Files

  • run.ts: serveAgent + /api/voice-live Dual-Brain WebSocket bridge (MockGeminiLiveTalker + live BidiGenerateContent client) and --smoke.
  • components/voice-dual-brain.js: Two-lane Substrate Shell inspector with AudioWorklet capture & playback.
  • PROMPT.md: Prompt to rebuild this lab.