ContextStrategySettings
SUPPORT · type · Type contract
Shared reduce-policy settings applied to the whole strategy.
Trigger and target fields follow the Core policy contract; omitted values fall back to the plan budget or to the trigger. Supplying steps disables generation and uses the explicit list.
Import
ts
import type { ContextStrategySettings } from '@jangts/agent-core/support';js
/** @typedef {import('@jangts/agent-core/support').ContextStrategySettings} ContextStrategySettings */Other public entry points:@jangts/agent-core/support, @jangts/agent-core/support/context.
Definition
Type: ContextStrategySettings
Type expression
ts
type ContextStrategySettings = Omit<
Extract<ContextPolicy, { mode: 'reduce' }>,
'mode' | 'steps'
> & {
readonly steps?: readonly ContextReduction[];
readonly compressors?: readonly ContextCompressor[];
readonly selectors?: readonly ContextSelector[];
};Field structure
| Field | Type | Required | Description |
|---|---|---|---|
selection | ContextSelection | undefined | Optional | 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. |
targetInputTokens | number | undefined | Optional | See the type definition and usage context. |
triggerTokens | number | undefined | Optional | See the type definition and usage context. |
steps | readonly ContextReduction[] | undefined | Optional | Read-only. See the type definition and usage context. |
compressors | readonly ContextCompressor[] | undefined | Optional | Read-only. See the type definition and usage context. |
selectors | readonly ContextSelector[] | undefined | Optional | Read-only. See the type definition and usage context. |
Examples
- Generate processing strategies from history semantics: Reuse fragment identity and hard budgets to generate complete steps and references for recent or continuity.
Reuse an existing fragment to generate a recent-history strategy
Beginner · Node.js
ts
import { Support } from '@jangts/agent-core';
const fragment = { id: 'history', maxChars: 4000 };
const strategy = Support.createContextStrategy({ kind: 'recent', fragment, field: 'messages' });
console.log(strategy.policy, strategy.compressors);js
import { Support } from '@jangts/agent-core';
const fragment = { id: 'history', maxChars: 4000 };
const strategy = Support.createContextStrategy({ kind: 'recent', fragment, field: 'messages' });
console.log(strategy.policy, strategy.compressors);Add kept groups and target size to the same configuration
Configuration · Node.js
ts
import { Support } from '@jangts/agent-core';
const fragment = { id: 'history', maxChars: 4000 };
const strategy = Support.createContextStrategy({ kind: 'recent', fragment, field: 'messages',
keepGroups: 3, targetChars: 2500, grouping: { kind: 'user-turn' },
});
console.log(strategy.policy);js
import { Support } from '@jangts/agent-core';
const fragment = { id: 'history', maxChars: 4000 };
const strategy = Support.createContextStrategy({ kind: 'recent', fragment, field: 'messages',
keepGroups: 3, targetChars: 2500, grouping: { kind: 'user-turn' },
});
console.log(strategy.policy);