validateContextPolicy
SUPPORT · function · Runtime value
Validate a complete context policy and every handler it can reference.
Handler IDs must be unique and each handler must declare a non-negative integer call ceiling. Reduction targets and selection modes are checked by their own catalog entries.
Import
import { validateContextPolicy } from '@jangts/agent-core/support';import { validateContextPolicy } from '@jangts/agent-core/support';Other public entry points:@jangts/agent-core/support, @jangts/agent-core/support/context.
Definition
Call
validateContextPolicy(policy: ContextPolicy, compressors: readonly ContextCompressor[], selectors?: readonly ContextSelector[]): voidValidate a complete context policy and every handler it can reference.
Handler IDs must be unique and each handler must declare a non-negative integer call ceiling. Reduction targets and selection modes are checked by their own catalog entries.
| Parameter | Type | Passing | Description |
|---|---|---|---|
policy | ContextPolicy | Required | — |
compressors | readonly ContextCompressor[] | Required | — |
selectors | readonly ContextSelector[] | Optional | — |
Optional shapes of Parameter policy: choose one shape; required fields for each branch are listed separately.
Branch 1
| Field | Type | Required | Description |
|---|---|---|---|
mode | "validate" | Required | See the type definition and usage context. |
Branch 2
| Field | Type | Required | Description |
|---|---|---|---|
mode | "reduce" | Required | See the type definition and usage context. |
triggerChars | number | undefined | Optional | See the type definition and usage context. |
targetInputChars | number | undefined | Optional | See the type definition and usage context. |
triggerTokens | number | undefined | Optional | See the type definition and usage context. |
targetInputTokens | number | undefined | Optional | See the type definition and usage context. |
selection | ContextSelection | undefined | Optional | See the type definition and usage context. |
steps | readonly ContextReduction[] | Required | See the type definition and usage context. |
Branch 3
| Field | Type | Required | Description |
|---|---|---|---|
mode | "audit" | Required | See the type definition and usage context. |
mutableFragmentIds | readonly string[] | Required | See the type definition and usage context. |
Returns: void.
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
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);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.
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);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);Limit the mutable range for the App's own processing
Extension · Node.js
Auditing also requires the ContextPlan to carry the original fragments; listing IDs alone does not modify or publish material by itself.
import { Support } from '@jangts/agent-core';
import type { ContextPolicy } from '@jangts/agent-core/support/context';
const policy: ContextPolicy = { mode: 'audit', mutableFragmentIds: ['history'] };
Support.validateContextPolicy(policy, [], []);
console.log(policy.mutableFragmentIds);import { Support } from '@jangts/agent-core';
const policy = { mode: 'audit', mutableFragmentIds: ['history'] };
Support.validateContextPolicy(policy, [], []);
console.log(policy.mutableFragmentIds);