API Reference
ToolMessage
Defined in: types/tool-message.ts:37
A tool-result turn — the response to a single ToolCall.
Remarks
The loop produces exactly one ToolMessage per tool call the assistant made,
carrying that tool's output in content. It is linked back to the call it
answers by ToolMessage.tool_call_id (which equals the call's id), so
the model can tell which result belongs to which call. N tool calls in a turn
yield N tool messages, paired one-to-one by id.
Abstraction over — OpenAI's tool message ({ role, tool_call_id, content });
toolName and isError are this loop's extensions (plus timestamp from the
base). Egress drops the extensions, so only the three standard fields cross the
wire (see toChatMessage).
Example
Wire shape (OpenAI chat-completions)
{
"role": "tool",
"tool_call_id": "call_abc123",
"content": "72°F and sunny"
}See
Extends
MessageBase
Properties
| Property | Type | Description | Overrides | Inherited from | Defined in |
|---|---|---|---|---|---|
content | string | A tool result is always plain text (narrows the multimodal base). | MessageBase.content | - | types/tool-message.ts:42 |
isError? | boolean | [extension — not in the OpenAI spec] Marks a tool result as an error, so hooks and UIs can treat a failed call differently from a normal one. Set by the loop when a tool throws (see Tool.execute); the wire format carries only plain content. | - | - | types/tool-message.ts:63 |
role | Tool | Discriminant: a tool-result turn. | - | - | types/tool-message.ts:39 |
timestamp? | number | [extension — not in the OpenAI spec] Creation time (ms since epoch), for ordering. | - | MessageBase.timestamp | types/message-base.ts:35 |
tool_call_id | string | Standard wire field: the id of the ToolCall this message is the response to — equal to that call's id. Always set. | - | - | types/tool-message.ts:48 |
toolName? | string | [extension — not in the OpenAI spec] The function name this result answers. Lets the loop route results and lets stop conditions match on tool name without re-deriving it from tool_call_id; OpenAI tool messages omit it. | - | - | types/tool-message.ts:55 |