VirtualConversationHandle class

A ConversationHandle backed by the virtual-session multiplexer.

On LiteRT-LM 0.18 the engine allowed only ONE live conversation at a time (upstream #966); 0.19 lifts it, but only where several live conversations were verified does an openSession session get its own (OpenSessionBacking.native). Everywhere else each virtual handle keeps its full multimodal turn history in Dart and, on every generate, asks the client to (re)materialize the single shared conversation seeded with THIS session's history via a messages_json preface. The client serializes turns with a mutex, so the sessions are logically concurrent (independent contexts) but inference is serialized (one generation at a time) — verified by the session_switch / messages_preface smoke tests.

Same-session follow-up turns reuse the live conversation (no rebuild), except under freshConversationEachTurn; only switching to a different session pays the teardown+replay cost.

Implemented types

Constructors

VirtualConversationHandle({required LiteRtLmFfiClient client, required String? systemMessage, required String? toolsJson, required Sampler sampling, required bool samplingExplicit, required MediaOrder multimodalOrder, required bool filterChannelContent, required ToolCallReader toolCallsOf, int? maxOutputTokens, Constraint? constraint, ConversationExtras extras = ConversationExtras.none, List<Map<String, Object?>> initialHistory = const [], bool freshConversationEachTurn = false})

Properties

client → LiteRtLmFfiClient
final
constraint → Constraint?
final
extras → ConversationExtras
final
filterChannelContent → bool
final
freshConversationEachTurn → bool
Every turn, this session's follow-ups included, rebuilds the shared conversation from the history (liteRtLmFreshConversationEachTurn).
final
hashCode → int
The hash code for this object.
no setterinherited
lastTurnCode → int?
The absl status code native's last send ended with (§23's record): non-zero only for NativeLastTurnEnd.failed and NativeLastTurnEnd.contextFull; null when lastTurnEnd is.
no setteroverride
lastTurnEnd → NativeLastTurnEnd?
How native's last send on this conversation ended (§23's record, read when the send ended), or null before one has ended here.
no setteroverride
maxOutputTokens → int?
final
multimodalOrder → MediaOrder
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sampling → Sampler
final
samplingExplicit → bool
final
systemMessage → String?
final
token → Object
Unique identity for this virtual session — the client uses it to tell whether the live conversation already holds this session's history.
final
toolCallsOf → ToolCallReader
The tool calls of a raw reply, for the assistant turn a switch replays.
final
toolsJson → String?
final

Methods

cancelGeneration() → void
override
chat(String text, {List<Uint8List>? imageBytes, Uint8List? audioBytes, bool enableThinking = false}) → Stream<String>
override
chatRaw(String text, {List<Uint8List>? imageBytes, Uint8List? audioBytes, bool enableThinking = false}) → Stream<String>
override
chatRawMessage(String messageJson, {bool enableThinking = false, SendOptions options = SendOptions.none}) → Stream<String>
Streams raw SDK JSON for a prebuilt message. This is how tool results go back: chatRaw always sends role user, and a tool result has to be role tool for the model to read it as the answer to its call.
override
close() → void
override
getSessionMetrics() → BenchmarkInfo
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rewindStoppedTurn(Map<String, Object?>? partialReply) → Future<StoppedTurnRewind>
The multiplexer rebuilds a stopped conversation from this session's full multimodal history at its next turn.
override
tokenCount(String text) → Future<int?>
The tokenizer belongs to the engine, not to a conversation, so a virtual session answers this as accurately as a live one.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited