ModelToolResultMessage
CORE · type · 类型合同
Tool result turn; toolCallId is required and images/tool declarations are rejected.
导入
ts
import type { ModelToolResultMessage } from '@jangts/agent-core/types';1
js
/** @typedef {import('@jangts/agent-core/types').ModelToolResultMessage} ModelToolResultMessage */1
其他公开入口:@jangts/agent-core/types、@jangts/agent-core/structs。
定义
类型: ModelToolResultMessage
类型表达式
ts
type ModelToolResultMessage = ModelMessage & {
readonly role: 'tool';
readonly toolCallId: string;
readonly toolCalls?: never;
readonly images?: never;
};1
2
3
4
5
6
2
3
4
5
6
字段结构
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
role | "tool" | 必需 | 见类型定义及调用场景。 |
content | string | 必需 | Rendered text content sent to the model. |
images | undefined | 可省略 | User-supplied visual input. Binary payload is separate from the text character budget. |
toolCalls | undefined | 可省略 | Tool declarations made by an assistant turn; rejected on every other role at runtime. |
toolCallId | string | 必需 | Call id answered by a tool result; rejected on every other role at runtime. |
类型使用
在调用方读取该合同
ts
import type { ModelToolResultMessage } from '@jangts/agent-core/types';
// 在使用点保留原合同,TS 与 JS 具有相同的运行行为。
function inspect(value: ModelToolResultMessage) {
return value.role;
}1
2
3
4
5
6
2
3
4
5
6
js
/** @param {import('@jangts/agent-core/types').ModelToolResultMessage} value */
function inspect(value) {
return value.role;
}1
2
3
4
2
3
4