Follow along with the runnable example. This guide walks through the conversational agent example in
corti-examples — bootstrap your build from it or use it as reference.This builds on the agent lifecycle from On-Demand Agent and the threading pattern from Wake-Command Agent.The prompts used here are mere examples - be sure to test and refine the prompt to support your specific needs.
Configure for always-on capture
Enable interim results so transcripts arrive while the user is still speaking. Disable automatic punctuation to reduce noise in partial text, and enable audio events so the session can detect silence. See the conversational agent example incorti-examples for the full dictationConfig and event wiring.
Fire a speculative request on interim text
On the first interim of each turn, schedule a short debounce (200 ms) then fire a stateless agent call — nocontextId, so the real conversation thread is never touched. If the user keeps speaking, the timer resets and a fresh call fires with the updated text.
JavaScript
fireSpeculative sends the text to the agent without a contextId and stores the result in heldResponse. See the conversational agent example in corti-examples for the full implementation.
Debounce finals and flush the turn
Buffer consecutive final segments and restart a silence timer on every new transcript event. When speech genuinely pauses — the timer fires without interruption — treat it as a complete turn and callhandleFinal.
JavaScript
Commit the turn with the real context
WhenhandleFinal fires, cancel any pending speculative timer. If heldResponse is set, display it optimistically and then replace it in-place with the real contextual response. If not set, show a thinking spinner while the contextual call completes. The real messageSend always uses contextId to keep the thread coherent — pass the current one and update it from the response. See the conversational agent example in corti-examples for the full implementation.
See Context & Memory for how threads work in the Agentic Framework. A
404 on messageSend means the agent or context was deleted — recreate the agent and retry the turn without the stale contextId.Reset the conversation
To start over, callclient.agents.deleteContext(agentId, contextId) to remove the server-side thread, then clear contextId, heldResponse, finalBuffer, and the message list.
Next steps
Wake-Command Agent
Gate the agent behind a spoken wake phrase instead of forwarding every utterance.
On-Demand Agent
The agent lifecycle and message API, for a single isolated pass.
Context & Memory
How conversation threads and memory work in the Agentic Framework.
Example code
The complete, runnable conversational agent example in
corti-examples.Please contact us for help or questions.