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
