Skip to content

VoiceConversationDriver

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Runs the real-time conversation pipeline: audio comes in, text is transcribed, the existing run path processes it, and audio goes out.

public sealed class VoiceConversationDriver

objectVoiceConversationDriver

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Option A. Audio is not proxied to the real-time API of the provider; the streaming run path of the agent itself is called. The price is latency, and the return is everything: the run record, spans, cost, tool approval, tenancy and quota all work in a voice turn exactly as they do elsewhere. AgentPrism is a control plane; it cannot suspend those promises for voice.

The driver lives in AgentPrism.Core and is provider independent: it knows only the ISpeechTranscriber and ISpeechSynthesizer abstractions. ElevenLabs is one implementation.

The concurrency model is three rules: a single receive loop reads the frames; turn processing runs on a separate task (otherwise cancel could not be read until the turn ended); and every send passes through one gate, because a WebSocket supports only one send at a time.

VoiceConversationDriver(IAgentCatalog, AgentSessionManager, ChatHistoryProvider, IVoiceSessionStore, IAttachmentStore, AttachmentTypeGuard, IOptions<VoiceConversationOptions>, ILogger<VoiceConversationDriver>, ISpeechTranscriber?, ISpeechSynthesizer?, TimeProvider?)

Section titled “ VoiceConversationDriver(IAgentCatalog, AgentSessionManager, ChatHistoryProvider, IVoiceSessionStore, IAttachmentStore, AttachmentTypeGuard, IOptions<VoiceConversationOptions>, ILogger<VoiceConversationDriver>, ISpeechTranscriber?, ISpeechSynthesizer?, TimeProvider?)”

Initializes a new instance of the VoiceConversationDriver class.

public VoiceConversationDriver(IAgentCatalog catalog, AgentSessionManager sessions, ChatHistoryProvider chatHistory, IVoiceSessionStore store, IAttachmentStore attachments, AttachmentTypeGuard guard, IOptions<VoiceConversationOptions> options, ILogger<VoiceConversationDriver> logger, ISpeechTranscriber? transcriber, ISpeechSynthesizer? synthesizer, TimeProvider? timeProvider = null)

catalog IAgentCatalog

The agent catalog.

sessions AgentSessionManager

The session manager.

chatHistory ChatHistoryProvider

The chat history provider.

store IVoiceSessionStore

The conversation record store.

attachments IAttachmentStore

The attachment store.

guard AttachmentTypeGuard

The attachment type guard.

options IOptions<VoiceConversationOptions>

The conversation options.

logger ILogger<VoiceConversationDriver>

The logger.

transcriber ISpeechTranscriber?

The transcription provider. When it is null a conversation cannot open (see VoiceConversationDriver.IsReady).

synthesizer ISpeechSynthesizer?

The synthesis provider.

timeProvider TimeProvider?

The time source.

ArgumentNullException

One of the required dependencies is null.

Gets a value that indicates whether both providers that a conversation needs are registered.

public bool IsReady { get; }

bool

Transcription and synthesis are both necessary: with only one of them the conversation would be one way, and that is not a conversation.

Gets the per-tenant concurrent connection limiter.

public VoiceConnectionLimiter Limiter { get; }

VoiceConnectionLimiter

The endpoint reserves a slot before it upgrades the socket: when the limit is full the client sees an HTTP error. To close the socket after the upgrade is a far worse way to tell the client the reason.

Gets a value that indicates whether the audio is stored.

public bool PersistAudio { get; }

bool

The user interface shows this value to the user; the audio is never recorded silently.

RunAsync(WebSocket, VoiceConversationRequest, CancellationToken)

Section titled “ RunAsync(WebSocket, VoiceConversationRequest, CancellationToken)”

Runs one conversation connection from start to end.

public Task RunAsync(WebSocket socket, VoiceConversationRequest request, CancellationToken cancellationToken = default)

socket WebSocket

The upgraded socket.

request VoiceConversationRequest

The immutable facts of the connection.

cancellationToken CancellationToken

The server shutdown token.

Task

A task that completes when the connection closes.

ArgumentNullException

One of the parameters is null.

InvalidOperationException

VoiceConversationDriver.IsReady is false.