chore(context): Apply cruft removal and strict hyperparameter types

This commit is contained in:
Your Name
2026-04-05 21:31:43 +00:00
parent d7e96d1d1c
commit a1f2af0e9d
5 changed files with 42 additions and 18 deletions
+29
View File
@@ -2482,6 +2482,35 @@ const SETTINGS_SCHEMA = {
default: {},
showInDialog: false,
properties: {
maxPressureStrategy: {
type: 'string',
label: 'Max Pressure Strategy',
category: 'Context Management',
requiresRestart: true,
default: 'truncate',
description: 'Action to take when hitting the synchronous token ceiling.',
showInDialog: false,
enum: ['truncate', 'compress', 'rollingSummarizer'],
},
gcTarget: {
type: 'string',
label: 'GC Target',
category: 'Context Management',
requiresRestart: true,
default: 'incremental',
description: 'The target floor for synchronous context shedding.',
showInDialog: false,
enum: ['incremental', 'freeNTokens', 'max'],
},
freeTokensTarget: {
type: 'number',
label: 'Free Tokens Target',
category: 'Context Management',
requiresRestart: true,
default: undefined,
description: 'Amount of tokens to free when gcTarget is freeNTokens.',
showInDialog: false,
},
maxTokens: {
type: 'number',
label: 'Max Tokens',
+3 -7
View File
@@ -1133,10 +1133,8 @@ export class Config implements McpContext, AgentLoopContext {
maxTokens: params.contextManagement?.budget?.maxTokens ?? 150000,
retainedTokens:
params.contextManagement?.budget?.retainedTokens ?? 40000,
protectedEpisodes:
params.contextManagement?.budget?.protectedEpisodes ?? 1,
protectSystemEpisode:
params.contextManagement?.budget?.protectSystemEpisode ?? true,
gcTarget: params.contextManagement?.budget?.gcTarget ?? 'incremental',
freeTokensTarget: params.contextManagement?.budget?.freeTokensTarget ?? undefined,
maxPressureStrategy: params.contextManagement?.budget?.maxPressureStrategy ?? 'truncate',
},
strategies: {
@@ -1154,9 +1152,7 @@ export class Config implements McpContext, AgentLoopContext {
nodeThresholdTokens:
params.contextManagement?.strategies?.semanticCompression
?.nodeThresholdTokens ?? 5000,
compressionModel:
params.contextManagement?.strategies?.semanticCompression
?.compressionModel ?? 'chat-compression-2.5-flash-lite',
},
},
};
@@ -34,7 +34,7 @@ export class SemanticCompressionProcessor implements ContextProcessor {
this.config.getContextManagementConfig().strategies.semanticCompression;
// We estimate 4 chars per token for truncation logic
const thresholdChars = semanticConfig.nodeThresholdTokens * 4;
this.modelToUse = semanticConfig.compressionModel;
this.modelToUse = 'gemini-2.5-flash';
let currentDeficit = state.deficitTokens;
const newEpisodes = [...episodes];
+6 -9
View File
@@ -11,8 +11,7 @@ export const GENERALIST_PROFILE: ContextManagementConfig = {
maxPressureStrategy: 'truncate',
maxTokens: 150_000,
retainedTokens: 65_000,
protectedEpisodes: 1,
protectSystemEpisode: true,
gcTarget: 'incremental',
},
strategies: {
// Brutal fallback truncation threshold
@@ -22,7 +21,7 @@ export const GENERALIST_PROFILE: ContextManagementConfig = {
// Intelligently summarize large text blocks before they hit the truncation guillotine
semanticCompression: {
nodeThresholdTokens: 3000,
compressionModel: 'chat-compression-2.5-flash-lite',
},
},
};
@@ -33,15 +32,14 @@ export const POWER_USER_PROFILE: ContextManagementConfig = {
maxPressureStrategy: 'truncate',
maxTokens: 150_000, // The absolute ceiling
retainedTokens: 65_000, // The "bloom filter" backbuffer floor
protectedEpisodes: 1,
protectSystemEpisode: true,
gcTarget: 'incremental',
},
strategies: {
historySquashing: { maxTokensPerNode: 4000 },
toolMasking: { stringLengthThresholdTokens: 8000 },
semanticCompression: {
nodeThresholdTokens: 3000,
compressionModel: 'chat-compression-2.5-flash-lite',
},
},
};
@@ -53,15 +51,14 @@ export const STRESS_TEST_PROFILE: ContextManagementConfig = {
maxPressureStrategy: 'truncate',
maxTokens: 12_000,
retainedTokens: 6_000,
protectedEpisodes: 1,
protectSystemEpisode: true,
gcTarget: 'incremental',
},
strategies: {
historySquashing: { maxTokensPerNode: 2000 },
toolMasking: { stringLengthThresholdTokens: 2000 },
semanticCompression: {
nodeThresholdTokens: 1000,
compressionModel: 'gemini-2.5-flash',
},
},
};
+3 -1
View File
@@ -23,7 +23,9 @@ export interface ContextManagementConfig {
* - 'truncate': Drop oldest episodes until under limit (Instant, data loss)
* - 'compress': Block request, perform N-to-1 Snapshot generation, then proceed (Slow, no data loss)
*/
maxPressureStrategy: 'truncate' | 'compress';
maxPressureStrategy: 'truncate' | 'compress' | 'rollingSummarizer';
gcTarget: 'incremental' | 'freeNTokens' | 'max';
freeTokensTarget?: number;
};
/** Specific hyperparameters for degrading the context when over budget */