Skip to content
中文

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 ​

FieldTypeRequiredDescription
maxCalls8RequiredSee the type definition and usage context.
callTimeoutMs30000RequiredSee the type definition and usage context.
maxInputChars32000RequiredSee the type definition and usage context.
maxOutputChars16000RequiredSee the type definition and usage context.
maxSchemaChars16000RequiredSee the type definition and usage context.
maxOutputTokens1024RequiredSee the type definition and usage context.
stage"model"RequiredSee the type definition and usage context.
childrenReadonly<{ maxDepth: 1; maxConcurrentCalls: 1; maxChildren: 32; }>RequiredSee the type definition and usage context.

Examples ​

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);

API reference, usage examples and developer guides.