modelRunnerDefaults
CORE · constant · Runtime value
Import
ts
import { modelRunnerDefaults } from '@jangts/agent-core';js
import { modelRunnerDefaults } from '@jangts/agent-core';Other public entry points:@jangts/agent-core, @jangts/agent-core/types.
Definition
ts
const modelRunnerDefaults: Readonly<{ maxCalls: 8; callTimeoutMs: 30000; maxInputChars: 32000; maxOutputChars: 16000; maxSchemaChars: 16000; maxOutputTokens: 1024; stage: "model"; children: Readonly<{ maxDepth: 1; maxConcurrentCalls: 1; maxChildren: 32; }>; }>Field structure
| Field | Type | Required | Description |
|---|---|---|---|
maxCalls | 8 | Required | See the type definition and usage context. |
callTimeoutMs | 30000 | Required | See the type definition and usage context. |
maxInputChars | 32000 | Required | See the type definition and usage context. |
maxOutputChars | 16000 | Required | See the type definition and usage context. |
maxSchemaChars | 16000 | Required | See the type definition and usage context. |
maxOutputTokens | 1024 | Required | See the type definition and usage context. |
stage | "model" | Required | See the type definition and usage context. |
children | Readonly<{ maxDepth: 1; maxConcurrentCalls: 1; maxChildren: 32; }> | Required | See the type definition and usage context. |
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);Add an independent ordered output receiver
Extension · Node.js
sink.output is awaited in order. model.output is a proposal that has not been fully validated, so tool operations proposed by the model must not be executed here.
ts
import { ModelRunner } from '@jangts/agent-core/model';
const provider = {
async *stream(messages: readonly { content: string }[]) {
yield '收到:' + messages.at(-1)!.content;
},
};
const events: string[] = [];
const runner = new ModelRunner({ provider, sink: {
async output(event) { events.push(event.type); },
} });
const result = await runner.invoke('你好');
console.log(result.value, events);js
import { ModelRunner } from '@jangts/agent-core/model';
const provider = {
async *stream(messages) {
yield '收到:' + messages.at(-1).content;
},
};
const events = [];
const runner = new ModelRunner({ provider, sink: {
async output(event) { events.push(event.type); },
} });
const result = await runner.invoke('你好');
console.log(result.value, events);