ChatMessage

@Serializable
sealed interface ChatMessage

One message of a conversation with a ChatModel.

Messages are @Serializable, so a state that holds them can be saved by a checkpointer that uses kotlinx.serialization.

Inheritors

Types

Link copied to clipboard
@Serializable
@SerialName(value = "assistant")
data class Assistant(val text: String = "", val toolCalls: List<ToolCall> = emptyList(), val providerContent: JsonElement? = null, val truncated: Boolean = false) : ChatMessage

What the model answered: text, requests to run tools, or both.

Link copied to clipboard
@Serializable
@SerialName(value = "tool_result")
data class ToolResult(val toolCallId: String, val toolName: String, val text: String, val isError: Boolean = false) : ChatMessage

The outcome of one ToolCall, sent back to the model.

Link copied to clipboard
@Serializable
@SerialName(value = "user")
data class User(val text: String) : ChatMessage

What the user said.

Properties

Link copied to clipboard
abstract val text: String

The text of the message. Empty for an assistant message that only asks for tools.