liveBook · Manning

Message role

As explained in Designing AI Systems

A message role is a field that identifies whether a conversation message contains system instructions, user input, or an assistant response.

A message role identifies who produced an entry in an AI conversation. Use it to distinguish system instructions, user input, assistant responses, and tool results before storing a session or sending messages to a model. section 4.1 section 3.1.1

A role assigns each message to a participant or processing stage:

  • system carries instructions that shape assistant behavior. section 4.1
  • user carries human input, such as a question or follow-up. section 4.1
  • assistant carries generated responses or a request to invoke tools. section 4.1
  • tool carries the result of an external function call and links back through a tool call ID. section 4.1

Appointment availability

A session can begin with a system message defining the intake assistant, followed by a user asking about openings. The assistant emits a tool call instead of text; after the scheduling system returns a tool message, the assistant produces the available times. section 4.1

Listing 4.1 Message dataclass representing a single entry in the conversation
@dataclass
class Message:
    role: str
    content: Optional[str] = None
    tool_calls: Optional[List[ToolCall]] = None    #A
    tool_call_id: Optional[str] = None    #A
    timestamp: datetime = field(default_factory=datetime.utcnow)
 
@dataclass  
class ToolCall:
    id: str    #B
    type: Literal["function"]
    function: Function
 
@dataclass 
class Function:
    name: str
    arguments: str    #C
 

A Message dataclass stores the role alongside content, optional tool calls, an optional tool call ID, and a timestamp; related ToolCall and Function structures carry invocation details. section 4.1

How Designing AI Systems covers it

How deep it goes
Defines four roles and shows dataclass fields plus tool-call linkage, but does not detail provider-specific protocol translation.
Examples
Uses patient intake questions, appointment availability, scheduling tool calls, and Python Message and Session dataclasses.
What you can do after
Build it from scratch by representing conversations as role-bearing messages and matching tool results to originating calls.
How it connects
Connects message roles to sessions, system prompts, conversation history, tool calls, model services, and token usage.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Designing AI Systems. The section links point to the parts of the book it draws on.