Cartesiandocs

Android · cartesian-core

ChatSession

Conversation state, streaming answers, events and follow-up suggestions.

val session: ChatSession = client.chat
kotlin

State

stateStateFlow<ChatState>

An immutable snapshot of the current thread. It updates on every streamed frame.

eventsSharedFlow<ChatEvent>

One-off events: TurnStarted, ProductsShown, CartChanged, TurnFinished, Error.

suggestionsStateFlow<List<String>>

Follow-up questions for the latest finished answer. Cleared when a new turn starts.

threadIdString?

Methods

MethodDescription
suspend send(text)Starts a turn, creating a thread if there isn't one. Throws Busy if a turn is running.
suspend stop()Interrupts the running turn
suspend newChat(): BooleanClears the state for a new thread. Returns false while a turn is running.
suspend open(threadId)Loads a past thread and its transcript
suspend retry()Re-sends the last question after a failure
suspend rate(messageId, rating)Rating.Up or Rating.Down
suspend dismissError()Clears state.error

ChatState

FieldType
threadIdString?
messagesList<ChatMessage>: UserMessage or AssistantMessage
isRespondingBoolean
isLoadingBoolean (opening a thread)
isEmptyBoolean
errorString?
feedbackMap<messageId, Rating>

AssistantMessage

FieldTypeDescription
textStringMarkdown answer, streamed
thinkingStringReasoning summary, if the backend sends one
stepsList<AgentStep>Activity trace: title, detail, phase (Started, Completed, Failed), kind (Search, Tool, System), tool
activeStepAgentStep?The step currently running
productsList<Product>Products shown with the answer
comparisonsList<Comparison>
cartUpdatesList<CartUpdate>operation, changedCount, itemCount, total, currency
statusMessageStatusStreaming, Done, Stopped or Failed
errorString?
elapsedSecondsInt?