feat(core): Improvements to the AgentHistoryProvider.

This commit is contained in:
Your Name
2026-03-28 03:49:54 +00:00
parent cc874e9693
commit a9ddd90f59
21 changed files with 1718 additions and 303 deletions
+4 -8
View File
@@ -975,14 +975,10 @@ export async function loadCliConfig(
disabledSkills: settings.skills?.disabled,
experimentalJitContext: settings.experimental?.jitContext,
experimentalMemoryManager: settings.experimental?.memoryManager,
experimentalAgentHistoryTruncation:
settings.experimental?.agentHistoryTruncation,
experimentalAgentHistoryTruncationThreshold:
settings.experimental?.agentHistoryTruncationThreshold,
experimentalAgentHistoryRetainedMessages:
settings.experimental?.agentHistoryRetainedMessages,
experimentalAgentHistorySummarization:
settings.experimental?.agentHistorySummarization,
contextManagement: {
enabled: settings.experimental?.contextManagement,
...settings?.contextManagement,
},
modelSteering: settings.experimental?.modelSteering,
topicUpdateNarration: settings.experimental?.topicUpdateNarration,
toolOutputMasking: settings.experimental?.toolOutputMasking,
+126 -34
View File
@@ -2141,44 +2141,13 @@ const SETTINGS_SCHEMA = {
'Replace the built-in save_memory tool with a memory manager subagent that supports adding, removing, de-duplicating, and organizing memories.',
showInDialog: true,
},
agentHistoryTruncation: {
contextManagement: {
type: 'boolean',
label: 'Agent History Truncation',
label: 'Enable Context Management',
category: 'Experimental',
requiresRestart: true,
default: false,
description:
'Enable truncation window logic for the Agent History Provider.',
showInDialog: true,
},
agentHistoryTruncationThreshold: {
type: 'number',
label: 'Agent History Truncation Threshold',
category: 'Experimental',
requiresRestart: true,
default: 30,
description:
'The maximum number of messages before history is truncated.',
showInDialog: true,
},
agentHistoryRetainedMessages: {
type: 'number',
label: 'Agent History Retained Messages',
category: 'Experimental',
requiresRestart: true,
default: 15,
description:
'The number of recent messages to retain after truncation.',
showInDialog: true,
},
agentHistorySummarization: {
type: 'boolean',
label: 'Agent History Summarization',
category: 'Experimental',
requiresRestart: true,
default: false,
description:
'Enable summarization of truncated content via a small model for the Agent History Provider.',
description: 'Enable logic for context management.',
showInDialog: true,
},
topicUpdateNarration: {
@@ -2457,6 +2426,129 @@ const SETTINGS_SCHEMA = {
},
},
contextManagement: {
type: 'object',
label: 'Context Management',
category: 'Experimental',
requiresRestart: true,
default: {},
description:
'Settings for agent history and tool distillation context management.',
showInDialog: false,
properties: {
historyWindow: {
type: 'object',
label: 'History Window Settings',
category: 'Context Management',
requiresRestart: true,
default: {},
showInDialog: false,
properties: {
truncationThreshold: {
type: 'number',
label: 'Truncation Threshold',
category: 'Context Management',
requiresRestart: true,
default: 25,
description:
'The maximum number of messages before history is truncated.',
showInDialog: true,
},
retainedMessages: {
type: 'number',
label: 'Retained Messages',
category: 'Context Management',
requiresRestart: true,
default: 20,
description:
'The number of recent messages to retain after truncation.',
showInDialog: true,
},
targetRetainedTokens: {
type: 'number',
label: 'Target Retained Tokens',
category: 'Context Management',
requiresRestart: true,
default: 40000,
description:
'The target number of tokens to retain in the session history.',
showInDialog: true,
},
},
},
messageLimits: {
type: 'object',
label: 'Message Limits',
category: 'Context Management',
requiresRestart: true,
default: {},
showInDialog: false,
properties: {
normalTokenLimit: {
type: 'number',
label: 'Normal Token Limit',
category: 'Context Management',
requiresRestart: true,
default: 2500,
description:
'The target number of tokens to budget for a normal conversation turn.',
showInDialog: true,
},
maximumTokenLimit: {
type: 'number',
label: 'Maximum Token Limit',
category: 'Context Management',
requiresRestart: true,
default: 12000,
description:
'The maximum number of tokens a single conversation turn can consume before truncation.',
showInDialog: true,
},
normalizationHeadRatio: {
type: 'number',
label: 'Normalization Head Ratio',
category: 'Context Management',
requiresRestart: true,
default: 0.25,
description:
'The ratio of tokens to retain from the beginning of a truncated message (0.0 to 1.0).',
showInDialog: true,
},
},
},
toolDistillation: {
type: 'object',
label: 'Tool Distillation',
category: 'Context Management',
requiresRestart: true,
default: {},
showInDialog: false,
properties: {
truncationThreshold: {
type: 'number',
label: 'Tool Truncation Threshold',
category: 'Context Management',
requiresRestart: true,
default: 40000,
description:
'Maximum characters to show when truncating large tool outputs. Set to 0 or negative to disable truncation.',
showInDialog: true,
},
summarizationThreshold: {
type: 'number',
label: 'Tool Summarization Threshold',
category: 'Context Management',
requiresRestart: true,
default: 80000,
description:
'Threshold above which truncated tool outputs will be summarized by an LLM.',
showInDialog: true,
},
},
},
},
},
admin: {
type: 'object',
label: 'Admin',