ContextProcessingOptions
SUPPORT · interface · Type contract
Runtime inputs for one processing run.
Import
ts
import type { ContextProcessingOptions } from '@jangts/agent-core/support';1
js
/** @typedef {import('@jangts/agent-core/support').ContextProcessingOptions} ContextProcessingOptions */1
Other public entry points:@jangts/agent-core/support, @jangts/agent-core/support/context.
Definition
ts
interface ContextProcessingOptions1
Extends or implements: ExecutionContext.
Field structure
| Field | Type | Required | Description |
|---|---|---|---|
stageId | string | Required | Read-only. Stage the processing belongs to; reported in diagnostics and selection calls. |
compressors | readonly ContextCompressor[] | Required | Read-only. Compressors available by handler id. |
selectors | readonly ContextSelector[] | undefined | Optional | Read-only. Selectors available by handler id; required only for model selection. |
callModel | ContextModelCall | Required | Read-only. See the type definition and usage context. |
remainingCalls | (() => number) | undefined | Optional | Read-only. Remaining model calls; used to reject unaffordable selections. |
tokenBudget | ContextTokenMeasurement | undefined | Optional | Read-only. Token measurement; without it, token triggers and targets cannot apply. |
logger | SubFlowLog | undefined | Optional | Read-only. Explicit optional recorder for this operation; never inferred from diagnostics. |
signal | AbortSignal | Required | Read-only. Non-optional cancellation signal; never undefined once execution has started. |
diagnostics | DiagnosticContext | undefined | Optional | Read-only. Diagnostic scope of the enclosing call, when recording is enabled. |
Member index
| Member | Purpose |
|---|---|
callModel | See the overload below for full inputs and outputs. |
Member details
callModel
ts
ContextProcessingOptions.callModel(request: ContextModelRequest): Promise<ModelResult<unknown>>1
| 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
- Context policy: validate, reduce, and audit: Support provides replaceable policy implementations while Core keeps the final input contract and budget checks.
Explicitly use a validation-only policy
Beginner · Node.js
ts
import { Support } from '@jangts/agent-core';
import type { ContextPolicy } from '@jangts/agent-core/support/context';
const policy: ContextPolicy = { mode: 'validate' };
Support.validateContextPolicy(policy, [], []);
console.log(policy.mode);1
2
3
4
5
2
3
4
5
js
import { Support } from '@jangts/agent-core';
const policy = { mode: 'validate' };
Support.validateContextPolicy(policy, [], []);
console.log(policy.mode);1
2
3
4
2
3
4
Configure reduction order from real business fragments
Configuration · Node.js
These numbers are explicit choices for the example business, not SDK recommendations for capacities that suit all models.
ts
import { Support } from '@jangts/agent-core';
import type { ContextPolicy } from '@jangts/agent-core/support/context';
const policy: ContextPolicy = { mode: 'reduce', triggerChars: 1800, targetInputChars: 1500,
selection: { mode: 'sequence' },
steps: [{ id: 'recent-history', kind: 'trim', fragmentId: 'history', field: 'messages',
grouping: { kind: 'user-turn' }, keepGroups: 2, targetChars: 1000 }],
};
Support.validateContextPolicy(policy, [], []);
console.log(policy.steps);1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
js
import { Support } from '@jangts/agent-core';
const policy = { mode: 'reduce', triggerChars: 1800, targetInputChars: 1500,
selection: { mode: 'sequence' },
steps: [{ id: 'recent-history', kind: 'trim', fragmentId: 'history', field: 'messages',
grouping: { kind: 'user-turn' }, keepGroups: 2, targetChars: 1000 }],
};
Support.validateContextPolicy(policy, [], []);
console.log(policy.steps);1
2
3
4
5
6
7
8
2
3
4
5
6
7
8