Chat Type

The Chat type orchestrates conversation context across history, dynamic context tables, and agent participants. It integrates with the ChatRoom plugin and supports multi-agent acknowledgement flows.

Creation Syntax

@historyTable new Table "from" "message" "timestamp" "role"
@contextTable new Table "from" "message" "timestamp" "role"
@assistantAgent new ChatAIAgent "assistant"
@chat new Chat historyTable contextTable assistantAgent

Arguments are: history variable, context variable, followed by one or more agent variables. The first agent is used as interrogator when chat.start is called.

Example

@chat new Chat historyTable contextTable assistantAgent
chat.start "User asks a question"
@ctx chat.getDynamicContext
@hist chat.getHistory

This pattern shows startup plus context and history retrieval. The full behavior is implemented in src/predefined/Chat.js.

Step-by-Step Interaction

The chat lifecycle starts when start forwards an initial message to the interrogator agent, which is usually the first registered participant. During execution, the notify method publishes responses to subscribers and forwards acknowledgement payloads to registered agents so internal state remains synchronized across participants. The methods getHistory and getContextTable expose the backing storage variables, while getContext and getDynamicContext compute conversational context snapshots that combine static context rows, optional UI context, and recent history entries.

Runtime Role Notes

The Chat type is the runtime glue between context storage, chat-room notifications, and agent acknowledgement callbacks, enabling multi-agent conversational orchestration in one object.