ModelStrategyOptions
SUPPORT · type · Type contract
Input of createModelStrategy: model selection, optional reasoning and budget plus explicit Core overrides. Explicit Core fields win over every generated value.
Import
ts
import type { ModelStrategyOptions } from '@jangts/agent-core/support';1
js
/** @typedef {import('@jangts/agent-core/support').ModelStrategyOptions} ModelStrategyOptions */1
Other public entry points:@jangts/agent-core/support, @jangts/agent-core/support/model.
Definition
Type: ModelStrategyOptions<Transports, Execution>
Type expression
ts
type ModelStrategyOptions<Transports extends readonly ModelTransportDefinition[] = readonly ModelTransportDefinition[], Execution = ExecutionOptions> = Partial<StrategyModel<Transports, Execution>> & {
/** An existing definition, or an ID in the explicitly supplied model catalog. */
readonly model: StrategyModel<Transports, Execution> | string;
/** Named model definitions; required when `model` is a string ID. */
readonly models?: Readonly<Record<string, StrategyModel<Transports, Execution>>>;
/** Names and supplier-specific implementations are declared by the App, never guessed. */
readonly reasoning?: string;
/** Per-reasoning overrides; entries are applied only when `reasoning` names them. */
readonly reasoningOptions?: Readonly<
Record<string, Partial<StrategyModel<Transports, Execution>>>
>;
/** Preset name, or an explicit partial budget; defaults to `medium`. */
readonly budget?: ModelBudgetStrategy;
};1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
Type parameters
| Type parameter | Constraint | Default type |
|---|---|---|
Transports | readonly ModelTransportDefinition[] | readonly ModelTransportDefinition[] |
Execution | — | ExecutionOptions |
Field structure
| Field | Type | Required | Description |
|---|---|---|---|
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. |
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. |
provider | ChatProvider | undefined | Optional | See the type definition and usage context. |
transports | Transports | undefined | Optional | See the type definition and usage context. |
sink | { output?: ModelRunnerPorts["onOutput"]; } | undefined | Optional | See the type definition and usage context. |
errors | { inputBudget?: ModelRunnerPorts["inputBudgetError"]; outputBudget?: ModelRunnerPorts["outputBudgetError"]; } | undefined | Optional | See the type definition and usage context. |
execution | Execution | undefined | Optional | See the type definition and usage context. |
model | string | StrategyModel<Transports, Execution> | Required | Read-only. An existing definition, or an ID in the explicitly supplied model catalog. |
models | Readonly<Record<string, StrategyModel<Transports, Execution>>> | undefined | Optional | Read-only. Named model definitions; required when model is a string ID. |
reasoning | string | undefined | Optional | Read-only. Names and supplier-specific implementations are declared by the App, never guessed. |
reasoningOptions | Readonly<Record<string, Partial<StrategyModel<Transports, Execution>>>> | undefined | Optional | Read-only. Per-reasoning overrides; entries are applied only when reasoning names them. |
budget | ModelBudgetStrategy | undefined | Optional | Read-only. Preset name, or an explicit partial budget; defaults to medium. |
Examples
- Model strategy: explicit selection and recommended budgets: Select from registered models and reasoning configurations, complete Core settings with local budget tiers, and keep per-field exact overrides.
Use a small budget for a short task and keep the same Core construction as needs grow
Beginner · Node.js
ts
import { AgentCoreEngine, ModelRunner, Support } from '@jangts/agent-core';
const provider = { async *stream() { yield '服务在线。'; } };
const config = Support.createModelStrategy({ model: { provider }, budget: 'small' });
const model = new ModelRunner(config);
console.log((await model.invoke('服务状态?')).value);
const agent = new AgentCoreEngine({ model: config });
console.log(agent.branch.agentId);1
2
3
4
5
6
7
2
3
4
5
6
7
js
import { AgentCoreEngine, ModelRunner, Support } from '@jangts/agent-core';
const provider = { async *stream() { yield '服务在线。'; } };
const config = Support.createModelStrategy({ model: { provider }, budget: 'small' });
const model = new ModelRunner(config);
console.log((await model.invoke('服务状态?')).value);
const agent = new AgentCoreEngine({ model: config });
console.log(agent.branch.agentId);1
2
3
4
5
6
7
2
3
4
5
6
7
Refer to an existing model by ID and register the reasoning scheme explicitly
Configuration · Node.js
The example Providers are fully offline. Reasoning parameters for real providers are implemented through each Provider's explicit configuration.
ts
import { ModelRunner, Support } from '@jangts/agent-core';
const fast = { async *stream() { yield '简短回答'; } };
const reasoned = { async *stream() { yield '经过复核的回答'; } };
const models = { fast: { provider: fast }, thorough: { provider: reasoned } };
const config = Support.createModelStrategy({ model: 'fast', models, budget: 'small',
reasoning: 'high', reasoningOptions: { high: { provider: reasoned } },
maxCalls: 1, maxOutputTokens: 1200,
});
console.log((await new ModelRunner(config).invoke('检查资料')).value);1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
js
import { ModelRunner, Support } from '@jangts/agent-core';
const fast = { async *stream() { yield '简短回答'; } };
const reasoned = { async *stream() { yield '经过复核的回答'; } };
const models = { fast: { provider: fast }, thorough: { provider: reasoned } };
const config = Support.createModelStrategy({ model: 'fast', models, budget: 'small',
reasoning: 'high', reasoningOptions: { high: { provider: reasoned } },
maxCalls: 1, maxOutputTokens: 1200,
});
console.log((await new ModelRunner(config).invoke('检查资料')).value);1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9