Skip to content
English

ModelToolResultMessage ​

CORE · type · 类型合同

Tool result turn; toolCallId is required and images/tool declarations are rejected.

导入 ​

ts
import type { ModelToolResultMessage } from '@jangts/agent-core/types';
js
/** @typedef {import('@jangts/agent-core/types').ModelToolResultMessage} ModelToolResultMessage */

其他公开入口:@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;
};

字段结构 ​

字段类型必需说明
role"tool"必需见类型定义及调用场景。
contentstring必需Rendered text content sent to the model.
imagesundefined可省略User-supplied visual input. Binary payload is separate from the text character budget.
toolCallsundefined可省略Tool declarations made by an assistant turn; rejected on every other role at runtime.
toolCallIdstring必需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;
}
js
/** @param {import('@jangts/agent-core/types').ModelToolResultMessage} value */
function inspect(value) {
  return value.role;
}

相关定义 ​

接口参考、使用示例与开发指南。