Skip to content
中文

ContextProcessingOptions ​

SUPPORT · interface · Type contract

Runtime inputs for one processing run.

Import ​

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

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

Definition ​

ts
interface ContextProcessingOptions

Extends or implements: ExecutionContext.

Field structure ​

FieldTypeRequiredDescription
stageIdstringRequiredRead-only. Stage the processing belongs to; reported in diagnostics and selection calls.
compressorsreadonly ContextCompressor[]RequiredRead-only. Compressors available by handler id.
selectorsreadonly ContextSelector[] | undefinedOptionalRead-only. Selectors available by handler id; required only for model selection.
callModelContextModelCallRequiredRead-only. See the type definition and usage context.
remainingCalls(() => number) | undefinedOptionalRead-only. Remaining model calls; used to reject unaffordable selections.
tokenBudgetContextTokenMeasurement | undefinedOptionalRead-only. Token measurement; without it, token triggers and targets cannot apply.
loggerSubFlowLog | undefinedOptionalRead-only. Explicit optional recorder for this operation; never inferred from diagnostics.
signalAbortSignalRequiredRead-only. Non-optional cancellation signal; never undefined once execution has started.
diagnosticsDiagnosticContext | undefinedOptionalRead-only. Diagnostic scope of the enclosing call, when recording is enabled.

Member index ​

MemberPurpose
callModelSee the overload below for full inputs and outputs.

Member details ​

callModel ​

ts
ContextProcessingOptions.callModel(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 ​

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);
js
import { Support } from '@jangts/agent-core';
const policy = { mode: 'validate' };
Support.validateContextPolicy(policy, [], []);
console.log(policy.mode);

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

API reference, usage examples and developer guides.