ContextSelectionCall
SUPPORT · interface · Type contract
Everything a selector may inspect for one decision.
Import
ts
import type { ContextSelectionCall } from '@jangts/agent-core/support';js
/** @typedef {import('@jangts/agent-core/support').ContextSelectionCall} ContextSelectionCall */Other public entry points:@jangts/agent-core/support, @jangts/agent-core/support/context.
Definition
ts
interface ContextSelectionCallField structure
| Field | Type | Required | Description |
|---|---|---|---|
stageId | string | Required | Read-only. See the type definition and usage context. |
candidates | readonly ContextSelectionCandidate[] | Required | Reducible candidates, already filtered and measured. |
fragments | readonly ContextFragment[] | Required | Only reducible fragments; never protected request or system fragments. |
currentTokens | number | undefined | Optional | Current input tokens, when a token budget applies. |
requiredReductionTokens | number | undefined | Optional | Tokens that must be removed to satisfy the token budget. |
currentChars | number | Required | See the type definition and usage context. |
requiredReductionChars | number | Required | Characters that must be removed to satisfy the character budget. |
remainingCalls | number | Required | Calls the selector may still spend through callModel. |
callModel | ContextModelCall | Required | See the type definition and usage context. |
Member index
| Member | Purpose |
|---|---|
callModel | See the overload below for full inputs and outputs. |
Member details
callModel
ts
ContextSelectionCall.callModel(request: ContextModelRequest): Promise<ModelResult<unknown>>| Parameter | Type | Passing | Description |
|---|---|---|---|
request | ContextModelRequest | Required | — |
Fields of request
| Field | Type | Required | Description |
|---|---|---|---|
modelId | string | undefined | Optional | Read-only. See the type definition and usage context. |
stageId | string | Required | Read-only. See the type definition and usage context. |
input | readonly ModelMessage[] | BuiltContext | Required | Read-only. See the type definition and usage context. |
maxOutputTokens | number | Required | Read-only. See the type definition and usage context. |
transport | string | Required | Read-only. See the type definition and usage context. |
Returns: Promise<ModelResult<unknown>>.
Awaited value: ModelResult<unknown>.
Return value structure
| Field | Type | Required | Description |
|---|---|---|---|
value | unknown | Required | Read-only. See the type definition and usage context. |
invocation | Readonly<ModelCallRecord> | Required | Read-only. See the type definition and usage context. |
Examples
- Selecting reduction steps: sequence, fixed, automatic, or model: One typed policy set expresses multiple scenarios while preserving exact parameters and App-defined selection.
Process in registered order
Beginner · Node.js
ts
import { Support } from '@jangts/agent-core';
Support.validateContextSelection({ mode: 'sequence' }, []);
console.log(Object.keys(Support.contextSelectionCatalog));js
import { Support } from '@jangts/agent-core';
Support.validateContextSelection({ mode: 'sequence' }, []);
console.log(Object.keys(Support.contextSelectionCatalog));Choose a policy per scenario with exact overrides
Configuration · Node.js
ts
import { Support } from '@jangts/agent-core';
const localOnly = { mode: 'fixed' as const, kind: 'trim' as const };
const preserveMore = { mode: 'auto' as const, maxTrimLossRatio: 0.1, reserveCalls: 2 };
Support.validateContextSelection(localOnly, []);
Support.validateContextSelection(preserveMore, []);
console.log(localOnly, preserveMore);js
import { Support } from '@jangts/agent-core';
const localOnly = { mode: 'fixed', kind: 'trim' };
const preserveMore = { mode: 'auto', maxTrimLossRatio: 0.1, reserveCalls: 2 };
Support.validateContextSelection(localOnly, []);
Support.validateContextSelection(preserveMore, []);
console.log(localOnly, preserveMore);