Chat messages
We support 4 types of message objects:SystemMessage: Instructions and context for the conversationUserMessage: Messages from end users to the assistantAssistantMessage: Responses from the AI assistant, potentially including tool callsToolMessage: Results from tools invoked during the conversation
content field, which can either be a str or a list of Content objects with text and/or reasoning. We don’t support audio/image/video content yet.
Each message also has an optional metadata field that can store additional structured information about the message as a dictionary.
Usage
The easiest way to convert adict into a ChatMessage is to use parse_chat_message:
Note on tool calls
There are two parts to a tool call:- On the
AssistantMessageitself, thetool_callsfield contains a list ofToolCallobjects. These represent calls to various tools the agent has access to. - The
ToolMessageobject is the output of the tool, e.g. a list of files after callingls.

ChatMessage module-attribute
DocentChatMessage module-attribute
BaseChatMessage
Bases:BaseModel
Base class for all chat message types.
Attributes:
| Name | Type | Description | |
|---|---|---|---|
id | `str | None` | Optional unique identifier for the message. |
content | `str | list[Content]` | The message content, either as a string or list of Content objects. |
role | Literal['system', 'user', 'assistant', 'tool'] | The role of the message sender (system, user, assistant, tool). | |
metadata | `dict[str, Any] | None` | Additional structured metadata about the message. |
docent/data_models/chat/message.py
docent/data_models/chat/message.py
text property
| Name | Type | Description |
|---|---|---|
str | str | The text content of the message. If content is a list, concatenates all text content elements with newlines. |
SystemMessage
Bases:BaseChatMessage
System message in a chat conversation.
Attributes:
| Name | Type | Description |
|---|---|---|
role | Literal['system'] | Always set to “system”. |
docent/data_models/chat/message.py
docent/data_models/chat/message.py
text property
| Name | Type | Description |
|---|---|---|
str | str | The text content of the message. If content is a list, concatenates all text content elements with newlines. |
UserMessage
Bases:BaseChatMessage
User message in a chat conversation.
Attributes:
| Name | Type | Description | |
|---|---|---|---|
role | Literal['user'] | Always set to “user”. | |
tool_call_id | `list[str] | None` | Optional list of tool call IDs this message is responding to. |
docent/data_models/chat/message.py
docent/data_models/chat/message.py
text property
| Name | Type | Description |
|---|---|---|
str | str | The text content of the message. If content is a list, concatenates all text content elements with newlines. |
AssistantMessage
Bases:BaseChatMessage
Assistant message in a chat conversation.
Attributes:
| Name | Type | Description | |
|---|---|---|---|
role | Literal['assistant'] | Always set to “assistant”. | |
model | `str | None` | Optional identifier for the model that generated this message. |
tool_calls | `list[ToolCall] | None` | Optional list of tool calls made by the assistant. |
docent/data_models/chat/message.py
docent/data_models/chat/message.py
text property
| Name | Type | Description |
|---|---|---|
str | str | The text content of the message. If content is a list, concatenates all text content elements with newlines. |
DocentAssistantMessage
Bases:AssistantMessage
Assistant message in a chat session with additional chat-specific metadata.
This extends AssistantMessage with fields that are only relevant in Docent chat contexts
Attributes:
| Name | Type | Description | |
|---|---|---|---|
citations | `list[InlineCitation] | None` | Optional list of citations referenced in the message content. |
suggested_messages | `list[str] | None` | Optional list of suggested followup messages. |
docent/data_models/chat/message.py
docent/data_models/chat/message.py
text property
| Name | Type | Description |
|---|---|---|
str | str | The text content of the message. If content is a list, concatenates all text content elements with newlines. |
ToolMessage
Bases:BaseChatMessage
Tool message in a chat conversation.
Attributes:
| Name | Type | Description | |
|---|---|---|---|
role | Literal['tool'] | Always set to “tool”. | |
tool_call_id | `str | None` | Optional ID of the tool call this message is responding to. |
function | `str | None` | Optional name of the function that was called. |
error | `dict[str, Any] | None` | Optional error information if the tool call failed. |
docent/data_models/chat/message.py
docent/data_models/chat/message.py
text property
| Name | Type | Description |
|---|---|---|
str | str | The text content of the message. If content is a list, concatenates all text content elements with newlines. |
parse_chat_message
| Name | Type | Description | Default | |
|---|---|---|---|---|
message_data | `dict[str, Any] | ChatMessage` | A dictionary or ChatMessage object representing a chat message. | required |
| Name | Type | Description |
|---|---|---|
ChatMessage | ChatMessage | An instance of a ChatMessage subclass based on the role. |
| Type | Description |
|---|---|
ValueError | If the message role is unknown. |
docent/data_models/chat/message.py
docent/data_models/chat/message.py
parse_docent_chat_message
| Name | Type | Description | Default | |
|---|---|---|---|---|
message_data | `dict[str, Any] | DocentChatMessage` | A dictionary or ChatSessionMessage object representing a chat session message. | required |
| Name | Type | Description |
|---|---|---|
ChatSessionMessage | DocentChatMessage | An instance of a ChatSessionMessage subclass based on the role. |
| Type | Description |
|---|---|
ValueError | If the message role is unknown. |
docent/data_models/chat/message.py
docent/data_models/chat/message.py
Content module-attribute
BaseContent
Bases:BaseModel
Base class for all content types in chat messages.
Provides the foundation for different content types with a discriminator field.
Attributes:
| Name | Type | Description |
|---|---|---|
type | Literal['text', 'reasoning', 'image', 'audio', 'video'] | The content type identifier, used for discriminating between content types. |
docent/data_models/chat/content.py
docent/data_models/chat/content.py
ContentText
Bases:BaseContent
Text content for chat messages.
Represents plain text content in a chat message.
Attributes:
| Name | Type | Description | |
|---|---|---|---|
type | Literal['text'] | Fixed as “text” to identify this content type. | |
text | str | The actual text content. | |
refusal | `bool | None` | Optional flag indicating if this is a refusal message. |
docent/data_models/chat/content.py
docent/data_models/chat/content.py
ContentReasoning
Bases:BaseContent
Reasoning content for chat messages.
Represents reasoning or thought process content in a chat message.
Attributes:
| Name | Type | Description | |
|---|---|---|---|
type | Literal['reasoning'] | Fixed as “reasoning” to identify this content type. | |
reasoning | str | The actual reasoning text. | |
signature | `str | None` | Optional signature associated with the reasoning. |
redacted | bool | Flag indicating if the reasoning has been redacted. |
docent/data_models/chat/content.py
docent/data_models/chat/content.py
ToolCall dataclass
Tool call information.
Attributes:
| Name | Type | Description | |
|---|---|---|---|
id | str | Unique identifier for tool call. | |
type | `Literal[‘function’] | None` | Type of tool call. Can only be “function” or None. |
function | str | Function called. | |
arguments | dict[str, Any] | Arguments to function. | |
parse_error | `str | None` | Error which occurred parsing tool call. |
view | `ToolCallContent | None` | Custom view of tool call input. |
docent/data_models/chat/tool.py
docent/data_models/chat/tool.py
ToolCallContent
Bases:BaseModel
Content to include in tool call view.
Attributes:
| Name | Type | Description | |
|---|---|---|---|
title | `str | None` | Optional (plain text) title for tool call content. |
format | Literal['text', 'markdown'] | Format (text or markdown). | |
content | str | Text or markdown content. |
docent/data_models/chat/tool.py
docent/data_models/chat/tool.py
ToolParam
Bases:BaseModel
A parameter for a tool function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | The name of the parameter. | required | |
description | A description of what the parameter does. | required | |
input_schema | JSON Schema describing the parameter’s type and validation rules. | required |
docent/data_models/chat/tool.py
docent/data_models/chat/tool.py
ToolParams
Bases:BaseModel
Description of tool parameters object in JSON Schema format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type | The type of the parameters object, always ‘object’. | required | |
properties | Dictionary mapping parameter names to their ToolParam definitions. | required | |
required | List of required parameter names. | required | |
additionalProperties | Whether additional properties are allowed beyond those specified. Always False. | required |
docent/data_models/chat/tool.py
docent/data_models/chat/tool.py
ToolInfo
Bases:BaseModel
Specification of a tool (JSON Schema compatible).
If you are implementing a ModelAPI, most LLM libraries can
be passed this object (dumped to a dict) directly as a function
specification. For example, in the OpenAI provider:
model_dump() on the parameters field. For example, in the
Anthropic provider:
| Name | Type | Description |
|---|---|---|
name | str | Name of tool. |
description | str | Short description of tool. |
parameters | ToolParams | JSON Schema of tool parameters object. |
docent/data_models/chat/tool.py
docent/data_models/chat/tool.py

