Skip to content
English

ResolvedSessionCall ​

SUPPORT · interface · 类型合同

One completed call with host-facing resolution; unknown tools and bad JSON stay non-fatal.

导入 ​

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

其他公开入口:@jangts/agent-core、@jangts/agent-core/types、@jangts/agent-core/support、@jangts/agent-core/support/model。

定义 ​

ts
interface ResolvedSessionCall

继承或实现: ModelSessionCall。

字段结构 ​

字段类型必需说明
toolIdstring | undefined可省略只读。Registered tool id, absent when the name is unknown to this stage.
inputRecord<string, unknown> | undefined可省略只读。Parsed arguments, absent when parsing failed or the tool is unknown.
problem"unknown-tool" | "invalid-arguments" | undefined可省略只读。Non-fatal problem the workflow should turn into a tool error message.
indexnumber必需只读。Provider index used to join streamed fragments.
idstring必需只读。Provider call id, echoed by the matching tool result.
namestring必需只读。Declared function name exactly as returned by the model.
argumentsstring必需只读。Raw JSON argument text exactly as returned by the model.
argumentCharsnumber必需只读。Characters counted for the output budget.

使用示例 ​

创建具名文本传输 ​

入门 · Node.js

ts
import { ModelRunner, Support } from '@jangts/agent-core';
const text = Support.createTextTransport({ id: 'brief', options: { temperature: 0.2 } });
const runner = new ModelRunner({ provider: { async *stream() { yield '服务正常'; } }, transports: [text] });
console.log((await runner.invoke({ input: '简答服务状态', transport: text })).value);
js
import { ModelRunner, Support } from '@jangts/agent-core';
const text = Support.createTextTransport({ id: 'brief', options: { temperature: 0.2 } });
const runner = new ModelRunner({ provider: { async *stream() { yield '服务正常'; } }, transports: [text] });
console.log((await runner.invoke({ input: '简答服务状态', transport: text })).value);

从同源 Tool 生成两个阶段的传输 ​

配置 · Node.js

ts
import { Support } from '@jangts/agent-core';
const inputSchema = Support.defineSchema({
  jsonSchema: { type: 'object', properties: {}, additionalProperties: false },
  parse(value: unknown) {
    if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).length) throw new TypeError('需要空对象');
    return {};
  },
});
const tools = Support.defineModelTools([
  { id: 'greet', description: '问候', inputSchema, resolve: () => 'greet' },
  { id: 'status', description: '状态查询', inputSchema, resolve: () => 'status' },
]);
const transport = Support.createStageModelTransport({ id: 'intent', tools,
  stages: [{ id: 'recognize', toolIds: ['greet', 'status'] }, { id: 'status-only', toolIds: ['status'] }],
});
console.log(transport.prepare('status-only').schemaChars);
js
import { Support } from '@jangts/agent-core';
const inputSchema = Support.defineSchema({
    jsonSchema: { type: 'object', properties: {}, additionalProperties: false },
    parse(value) {
        if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).length)
            throw new TypeError('需要空对象');
        return {};
    },
});
const tools = Support.defineModelTools([
    { id: 'greet', description: '问候', inputSchema, resolve: () => 'greet' },
    { id: 'status', description: '状态查询', inputSchema, resolve: () => 'status' },
]);
const transport = Support.createStageModelTransport({ id: 'intent', tools,
    stages: [{ id: 'recognize', toolIds: ['greet', 'status'] }, { id: 'status-only', toolIds: ['status'] }],
});
console.log(transport.prepare('status-only').schemaChars);

相关策略源码 ​

相关定义 ​

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