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';1
js
/** @typedef {import('@jangts/agent-core/model').ModelChildOptions} ModelChildOptions */1
Other public entry points:@jangts/agent-core, @jangts/agent-core/model, @jangts/agent-core/types, @jangts/agent-core/structs.
Definition
ts
interface ModelChildOptions1
Field structure
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Required | Read-only. Child stage id, reported in traces and events. |
maxCalls | number | Required | Read-only. Calls the child may use from the shared request budget. |
reserveCalls | number | Required | Read-only. Calls kept for the parent; the child cannot spend them. |
timeoutMs | number | Required | Read-only. Deadline for the child's own calls, in milliseconds. |
transports | readonly ModelTransportDefinition<unknown>[] | undefined | Optional | Read-only. Additional transports visible to the child. |
diagnostics | DiagnosticContext | undefined | Optional | Read-only. See the type definition and usage context. |
signal | AbortSignal | undefined | Optional | Read-only. Extra cancellation; can only shorten the parent's lifetime. |
Examples
- Child execution: isolated records, shared ancestor quota: A child Runner does not inherit conversation or the output receiver, but cannot bypass parent budget, cancellation, or deadlines.
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);1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
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);1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
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);1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
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);1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12