ContextHandlerReference
SUPPORT · interface · Type contract
Reference to a registered compressor or selector handler.
Import
ts
import type { ContextHandlerReference } from '@jangts/agent-core/support';js
/** @typedef {import('@jangts/agent-core/support').ContextHandlerReference} ContextHandlerReference */Other public entry points:@jangts/agent-core/support, @jangts/agent-core/support/context.
Definition
ts
interface ContextHandlerReferenceField structure
| Field | Type | Required | Description |
|---|---|---|---|
handlerId | string | Required | Read-only. Registered handler id; an unknown id is rejected before execution. |
Examples
- Context policy: validate, reduce, and audit: Support provides replaceable policy implementations while Core keeps the final input contract and budget checks.
- Selecting reduction steps: sequence, fixed, automatic, or model: One typed policy set expresses multiple scenarios while preserving exact parameters and App-defined selection.
- Support: the aggregate entry for recommended usage: Support aggregates recommended construction, policies, and same-source configuration generation; Core execution does not depend on this namespace.
- Generate processing strategies from history semantics: Reuse fragment identity and hard budgets to generate complete steps and references for recent or continuity.
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);