Skip to content
中文

ContextModelCall ​

SUPPORT · interface · Type contract

Same runner and same fixed invocation result as public model calls.

Import ​

ts
import type { ContextModelCall } from '@jangts/agent-core/support';
js
/** @typedef {import('@jangts/agent-core/support').ContextModelCall} ContextModelCall */

Other public entry points:@jangts/agent-core/support, @jangts/agent-core/support/context.

Definition ​

ts
interface ContextModelCall

Call ​

ts
ContextModelCall(request: ContextModelRequest): Promise<ModelResult<unknown>>
ParameterTypePassingDescription
requestContextModelRequestRequired—
Fields of request
FieldTypeRequiredDescription
modelIdstring | undefinedOptionalRead-only. See the type definition and usage context.
stageIdstringRequiredRead-only. See the type definition and usage context.
inputreadonly ModelMessage[] | BuiltContextRequiredRead-only. See the type definition and usage context.
maxOutputTokensnumberRequiredRead-only. See the type definition and usage context.
transportstringRequiredRead-only. See the type definition and usage context.

Returns: Promise<ModelResult<unknown>>.

Awaited value: ModelResult<unknown>.

Return value structure
FieldTypeRequiredDescription
valueunknownRequiredRead-only. See the type definition and usage context.
invocationReadonly<ModelCallRecord>RequiredRead-only. See the type definition and usage context.

Examples ​

Bind a text compression handler ​

Beginner · Node.js

ts
import { Support } from '@jangts/agent-core';
const compressor = Support.createContextCompressor({
  id: 'history-summary', instruction: '保留事实、时间和未完成事项,精简重复表达。',
  transport: 'core:plain-text', maxOutputTokens: 500,
  parse(value: unknown) { if (typeof value !== 'string' || !value.trim()) throw new TypeError('需要非空摘要'); return value; },
});
console.log(compressor.id);
js
import { Support } from '@jangts/agent-core';
const compressor = Support.createContextCompressor({
    id: 'history-summary', instruction: '保留事实、时间和未完成事项,精简重复表达。',
    transport: 'core:plain-text', maxOutputTokens: 500,
    parse(value) { if (typeof value !== 'string' || !value.trim())
        throw new TypeError('需要非空摘要'); return value; },
});
console.log(compressor.id);

A selector explicitly controls the visible excerpt range ​

Configuration · Node.js

selector-json must be registered by the App and return value={stepIds:string[]}; an ordinary text transport must not be treated as already parsed JSON. This example only shows handler assembly and sends no request.

ts
import { Support } from '@jangts/agent-core';
const selector = Support.createContextSelector({ id: 'select-reduction',
  transport: 'selector-json', maxOutputTokens: 200, maxExcerptChars: 1000,
});
console.log(selector.id);
js
import { Support } from '@jangts/agent-core';
const selector = Support.createContextSelector({ id: 'select-reduction',
    transport: 'selector-json', maxOutputTokens: 200, maxExcerptChars: 1000,
});
console.log(selector.id);

API reference, usage examples and developer guides.