Skip to content
中文

ModelChildOptions ​

CORE · interface · Type contract

Request-bound isolated runner settings; provider and ancestor budgets cannot be replaced.

Import ​

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

Other public entry points:@jangts/agent-core, @jangts/agent-core/model, @jangts/agent-core/types, @jangts/agent-core/structs.

Definition ​

ts
interface ModelChildOptions

Field structure ​

FieldTypeRequiredDescription
idstringRequiredRead-only. Child stage id, reported in traces and events.
maxCallsnumberRequiredRead-only. Calls the child may use from the shared request budget.
reserveCallsnumberRequiredRead-only. Calls kept for the parent; the child cannot spend them.
timeoutMsnumberRequiredRead-only. Deadline for the child's own calls, in milliseconds.
transportsreadonly ModelTransportDefinition<unknown>[] | undefinedOptionalRead-only. Additional transports visible to the child.
diagnosticsDiagnosticContext | undefinedOptionalRead-only. See the type definition and usage context.
signalAbortSignal | undefinedOptionalRead-only. Extra cancellation; can only shorten the parent's lifetime.

Examples ​

Configure a call quota for child execution ​

Beginner · Node.js

ts
import { ModelRunner } from '@jangts/agent-core/model';
const provider = {
  async *stream(messages: readonly { content: string }[]) {
    yield '收到:' + messages.at(-1)!.content;
  },
};
const parent = new ModelRunner({ provider, maxCalls: 3 });
const child = parent.createChild({ id: 'service-review', maxCalls: 1, reserveCalls: 1,
  timeoutMs: 10000, transports: [] });
const report = await child.invoke('独立核对服务状态');
console.log(report.value, parent.totalCallCount, child.callCount);
js
import { ModelRunner } from '@jangts/agent-core/model';
const provider = {
    async *stream(messages) {
        yield '收到:' + messages.at(-1).content;
    },
};
const parent = new ModelRunner({ provider, maxCalls: 3 });
const child = parent.createChild({ id: 'service-review', maxCalls: 1, reserveCalls: 1,
    timeoutMs: 10000, transports: [] });
const report = await child.invoke('独立核对服务状态');
console.log(report.value, parent.totalCallCount, child.callCount);

Let the parent finish the answer after the child report returns ​

Configuration · Node.js

The parent model is called only after the child task completes; there is no Promise.all. The parent still owns verifying the report source and business completeness.

ts
import { ModelRunner } from '@jangts/agent-core/model';
const provider = {
  async *stream(messages: readonly { content: string }[]) {
    yield '收到:' + messages.at(-1)!.content;
  },
};
const parent = new ModelRunner({ provider, maxCalls: 3 });
const child = parent.createChild({ id: 'service-review', maxCalls: 1, reserveCalls: 1,
  timeoutMs: 10000, transports: [] });
const report = await child.invoke('核对状态证据');
const answer = await parent.invoke('根据已核对报告回答:' + report.value);
console.log(answer.value);
js
import { ModelRunner } from '@jangts/agent-core/model';
const provider = {
    async *stream(messages) {
        yield '收到:' + messages.at(-1).content;
    },
};
const parent = new ModelRunner({ provider, maxCalls: 3 });
const child = parent.createChild({ id: 'service-review', maxCalls: 1, reserveCalls: 1,
    timeoutMs: 10000, transports: [] });
const report = await child.invoke('核对状态证据');
const answer = await parent.invoke('根据已核对报告回答:' + report.value);
console.log(answer.value);

API reference, usage examples and developer guides.