Normalized message types for AI agents. Includes Role enum, ChatMessage, Message (with session + sender), and AgentMessage for inter-agent bus.

Functions

assistant-msg

fn (content: Str): ChatMessage

Create a ChatMessage with role Assistant.

Example

::ai::message/assistant-msg("Hi there").content  // "Hi there"

format-chat-messages

fn (messages: Vec): Str

Render a Vec of ChatMessages as role: content lines.

Example

::ai::message/format-chat-messages([
    ::ai::message/user-msg("Hello"),
    ::ai::message/assistant-msg("Hi there")
])  // "user: Hello\nassistant: Hi there"

format-messages

fn (messages: Vec): Str

Render a Vec of Messages as [sender]: content lines for AI prompts.

Example

::ai::message/format-messages([
    {content: "Hello", sender: {id: "u1", name: "Ada"}},
    {content: "Hi Ada", sender: {id: "u2"}}
])  // "[Ada]: Hello\n[u2]: Hi Ada"

system-msg

fn (content: Str): ChatMessage

Create a ChatMessage with role System.

Example

::ai::message/system-msg("Be concise.").content  // "Be concise."

tool-msg

fn (content: Str): ChatMessage

Create a ChatMessage with role Tool — used for tool/function call results fed back into the model.

Example

::ai::message/tool-msg("18C and clear").content  // "18C and clear"

user-msg

fn (content: Str): ChatMessage

Create a ChatMessage with role User.

Example

::ai::message/user-msg("Hello").content  // "Hello"

Types

AgentMessage

AgentMessage type {
    session: ::ai::session/Session,
    sender: ::ai::session/Identity,
    from-agent: Str?,
    to-agent: Str?,
    content: Str,
    reply-event: Str?,
    correlation-id: Str?,
    metadata: Map?
}

A message routed between agents via the event bus. Carries session + sender.

ChatMessage

ChatMessage type {
    role: Role,
    content: Str
}

A single message in an AI conversation thread.

Message

Message type {
    id: Str,
    content: Str,
    sender: ::ai::session/Identity,
    session: ::ai::session/Session,
    timestamp: Int,
    source: Str?,
    metadata: Map?
}

A message in a conversation, carrying session and sender context.

Role

The role of a message in an AI conversation. The closed variant set covers the standard chat-completion roles: User, Assistant, System, and Tool (for tool/function call results that are fed back to the model). Tool is the only role recognized by every modern provider beyond the original three; rather than open the enum, we add it explicitly.