TeamState

@Serializable
data class TeamState(val messages: List<ChatMessage> = emptyList(), val tokens: TokenUsage = TokenUsage(), val assignments: List<Assignment> = emptyList(), val agent: String? = null)

The state of a supervisor: its conversation with the user and the work of its agents.

It is @Serializable, so a checkpointer that uses kotlinx.serialization can save it.

Constructors

Link copied to clipboard
constructor(messages: List<ChatMessage> = emptyList(), tokens: TokenUsage = TokenUsage(), assignments: List<Assignment> = emptyList(), agent: String? = null)
constructor(question: String)

Starts a conversation with question as the user's first message.

Properties

Link copied to clipboard

the TeamAgent.name of the agent that has the conversation in a handoffTeam, or null while it is still with the first agent.

Link copied to clipboard

The text of the supervisor's final answer, or null while the conversation does not end with one: before the first run, when the run paused in an agent, or when the team used its token budget before it had an answer. The text is incomplete when answerTruncated is true.

Link copied to clipboard

true when the model reached its output limit before it finished its last message, so answer is cut off.

Link copied to clipboard

every task the supervisor gave in this conversation, oldest first, with what the agent did on it.

Link copied to clipboard

the conversation of the supervisor, oldest message first. A task it gave an agent is a tool call in it, and the agent's answer is the result of that call.

Link copied to clipboard

the tokens of every answer of the supervisor, and of the agents that finished.

Functions

Link copied to clipboard
fun withUserMessage(text: String, attachments: List<Attachment> = emptyList()): TeamState

Returns this state with text and its attachments added as the user's next message, to continue the conversation.