ContextProcessingReport
SUPPORT · interface · Type contract
Facts recorded for one processing run.
Import
ts
import type { ContextProcessingReport } from '@jangts/agent-core/support';js
/** @typedef {import('@jangts/agent-core/support').ContextProcessingReport} ContextProcessingReport */Other public entry points:@jangts/agent-core/support, @jangts/agent-core/support/context.
Definition
ts
interface ContextProcessingReportField structure
| Field | Type | Required | Description |
|---|---|---|---|
mode | "reduce" | "validate" | "audit" | Required | Policy mode that ran. |
selection | "auto" | "fixed" | "sequence" | "model" | undefined | Optional | Selection mode applied, when the policy reduced content. |
decisions | { mode: ContextSelection["mode"]; stepIds: string[]; reason: string; }[] | undefined | Optional | Per-step selection decisions, kept for auditing auto and model choices. |
beforeChars | number | Required | Total characters before and after processing. |
afterChars | number | Required | See the type definition and usage context. |
tokens | { counterId: string; before: number; after: number; inputLimit: number; } | undefined | Optional | Token measurement, present only when a token budget was supplied. |
changes | { id: string; kind: "trim" | "compress" | "app"; fragmentId: string; beforeChars: number; afterChars: number; }[] | Required | Applied changes in execution order; app marks an App-supplied mutation. |
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
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);