Skip to content
中文

ContextSelectionCandidate ​

SUPPORT · interface · Type contract

Candidate step considered by selection, with its measured cost.

Import ​

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

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

Definition ​

ts
interface ContextSelectionCandidate

Field structure ​

FieldTypeRequiredDescription
idstringRequiredSee the type definition and usage context.
kind"trim" | "compress"RequiredSee the type definition and usage context.
fragmentIdstringRequiredSee the type definition and usage context.
charsnumberRequiredCurrent size of the candidate fragment, in JSON characters.
targetCharsnumberRequiredSize the step would reduce the fragment to.
requiredCallsnumberRequiredModel calls required to apply the step; 0 for local steps.
projectedCharsnumber | undefinedOptionalExact dry-run result for trim. Compression size is not predicted.
trimLossRationumber | undefinedOptionalFraction of characters removed by a trim step; meaningless for compression.

Examples ​

Process in registered order ​

Beginner · Node.js

ts
import { Support } from '@jangts/agent-core';
Support.validateContextSelection({ mode: 'sequence' }, []);
console.log(Object.keys(Support.contextSelectionCatalog));
js
import { Support } from '@jangts/agent-core';
Support.validateContextSelection({ mode: 'sequence' }, []);
console.log(Object.keys(Support.contextSelectionCatalog));

Choose a policy per scenario with exact overrides ​

Configuration · Node.js

ts
import { Support } from '@jangts/agent-core';
const localOnly = { mode: 'fixed' as const, kind: 'trim' as const };
const preserveMore = { mode: 'auto' as const, maxTrimLossRatio: 0.1, reserveCalls: 2 };
Support.validateContextSelection(localOnly, []);
Support.validateContextSelection(preserveMore, []);
console.log(localOnly, preserveMore);
js
import { Support } from '@jangts/agent-core';
const localOnly = { mode: 'fixed', kind: 'trim' };
const preserveMore = { mode: 'auto', maxTrimLossRatio: 0.1, reserveCalls: 2 };
Support.validateContextSelection(localOnly, []);
Support.validateContextSelection(preserveMore, []);
console.log(localOnly, preserveMore);

API reference, usage examples and developer guides.