tinker_cookbook.renderers.Message
class tinker_cookbook.renderers.Message(TypedDict)
Container for a single turn in a multi-turn conversation.
Parameters:
- role – Role String that denotes the source of the message, typically system, user, assistant, and tool.
- content – Content Content of the message, can be a string, or a list of ContentPart. When content is a list, it can contain TextPart, ImagePart, and ThinkingPart elements. ThinkingPart represents the model's internal reasoning (chain-of-thought).
- tool_calls – NotRequired[list[ToolCall]] Optional sequence of successfully parsed tool calls generated by the model.
- unparsed_tool_calls – NotRequired[list[UnparsedToolCall]] Optional sequence of tool calls that failed to parse (e.g., invalid JSON). The raw text is preserved for debugging or re-rendering.
- trainable – NotRequired[bool] Optional indicator whether this message should contribute to the training loss.
- tool_call_id – NotRequired[str] For tool result messages (role="tool"): ID correlating this result to a specific tool call. Used by renderers whose wire format references calls by ID (e.g., Kimi K2 renders "## Return of {tool_call_id}"). The value should match ToolCall.id from the assistant's tool_calls. Not all formats use IDs - GptOss/Harmony does not.
- name – NotRequired[str] For tool result messages (role="tool"): The function name that was called. Required by GptOss (renders "<|start|>functions.{name}..."), optional for others. When constructing tool results, include both name and tool_call_id when available since different renderers require different fields.
Fields:
- role (Role)
- content (Content)
- tool_calls (NotRequired[list[ToolCall]])
- unparsed_tool_calls (NotRequired[list['UnparsedToolCall']])
- trainable (NotRequired[bool])
- tool_call_id (NotRequired[str])
- name (NotRequired[str])