ModelRunnerSettings
CORE · interface · Type contract
Named settings keep all model limits together; output token reservation stays per call.
Import
ts
import type { ModelRunnerSettings } from '@jangts/agent-core/model';js
/** @typedef {import('@jangts/agent-core/model').ModelRunnerSettings} ModelRunnerSettings */Other public entry points:@jangts/agent-core, @jangts/agent-core/model, @jangts/agent-core/types, @jangts/agent-core/structs.
Definition
ts
interface ModelRunnerSettingsExtends or implements: Partial<ModelRuntimeConfig>.
Field structure
| Field | Type | Required | Description |
|---|---|---|---|
children | ModelChildPolicy | undefined | Optional | Read-only. See the type definition and usage context. |
maxInputChars | number | undefined | Optional | Character budget for the assembled input. |
maxSchemaChars | number | undefined | Optional | Character allowance for registered capability schemas. |
tokenBudget | ModelTokenBudget | undefined | Optional | See the type definition and usage context. |
maxOutputTokens | number | undefined | Optional | Default output reservation; invoke can override it for one call. |
maxCalls | number | undefined | Optional | Calls allowed for the whole request, including descendant runners' reservations. |
callTimeoutMs | number | undefined | Optional | Deadline for one provider call, in milliseconds. |
maxOutputChars | number | undefined | Optional | Cap on streamed output characters; exceeding it fails the call. |
usage | boolean | undefined | Optional | Request and record provider usage for each call. |
Examples
- ModelRunner: input can be shortened while the output contract stays the same: Execute one model interaction through the real Provider port and return a value plus the invocation for this call.
Two inputs for the same output
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 runner = new ModelRunner({ provider });
const first = await runner.invoke('你好');
const second = await runner.invoke({ input: '你好' });
console.log(first.value, second.value);
console.log(first.invocation.invocationId);js
import { ModelRunner } from '@jangts/agent-core/model';
const provider = {
async *stream(messages) {
yield '收到:' + messages.at(-1).content;
},
};
const runner = new ModelRunner({ provider });
const first = await runner.invoke('你好');
const second = await runner.invoke({ input: '你好' });
console.log(first.value, second.value);
console.log(first.invocation.invocationId);Add budget and request cancellation
Configuration · Node.js
ts
import { ModelRunner } from '@jangts/agent-core/model';
const provider = {
async *stream(messages: readonly { content: string }[]) {
yield '收到:' + messages.at(-1)!.content;
},
};
const runner = new ModelRunner({ provider, maxCalls: 2, maxInputChars: 4000,
maxOutputChars: 2000, callTimeoutMs: 15000,
execution: { signal: AbortSignal.timeout(20000) },
});
const result = await runner.invoke({ input: '你好', stageId: 'reply', maxOutputTokens: 600 });
console.log(result.value, runner.remainingCalls);js
import { ModelRunner } from '@jangts/agent-core/model';
const provider = {
async *stream(messages) {
yield '收到:' + messages.at(-1).content;
},
};
const runner = new ModelRunner({ provider, maxCalls: 2, maxInputChars: 4000,
maxOutputChars: 2000, callTimeoutMs: 15000,
execution: { signal: AbortSignal.timeout(20000) },
});
const result = await runner.invoke({ input: '你好', stageId: 'reply', maxOutputTokens: 600 });
console.log(result.value, runner.remainingCalls);