@@ -62,6 +62,15 @@ export interface AIAgentConfig {
6262 inputCostPerMillion : number ;
6363 outputCostPerMillion : number ;
6464 } ;
65+ maxIterations ?: number ;
66+ maxToolCalls ?: number ;
67+ maxRepeatedCalls ?: number ;
68+ compressionThreshold ?: number ;
69+ observationMaskingRecencyWindow ?: number ;
70+ observationMaskingTokenThreshold ?: number ;
71+ toolExecutionTimeout ?: number ;
72+ toolOutputMaxChars ?: number ;
73+ retryBudget ?: number ;
6574}
6675
6776export interface ProcessQueryResult {
@@ -88,6 +97,7 @@ export class AIAgentCore {
8897 private excludedTools ?: string [ ] ;
8998 private excludedFilePatterns ?: string [ ] ;
9099 private modelPricing ?: { inputCostPerMillion : number ; outputCostPerMillion : number } ;
100+ private observationMaskingOptions ?: { recencyWindow ?: number ; tokenThreshold ?: number } ;
91101
92102 private mcpToolsLoaded = false ;
93103 private mcpToolInfos : McpToolInfo [ ] = [ ] ;
@@ -111,15 +121,32 @@ export class AIAgentCore {
111121 this . excludedTools = config . excludedTools ;
112122 this . excludedFilePatterns = config . excludedFilePatterns ;
113123 this . modelPricing = config . modelPricing ;
124+ if ( config . observationMaskingRecencyWindow || config . observationMaskingTokenThreshold ) {
125+ this . observationMaskingOptions = {
126+ recencyWindow : config . observationMaskingRecencyWindow ,
127+ tokenThreshold : config . observationMaskingTokenThreshold ,
128+ } ;
129+ }
114130
115131 this . toolRegistry = new ToolRegistry ( ) ;
116132 this . registerAllTools ( ) ;
117133
118- const safetyManager = new ToolSafetyManager ( config . requireToolConfirmation ?? true ) ;
119- this . orchestrator = new ToolOrchestrator ( this . toolRegistry , safetyManager ) ;
134+ const safetyManager = new ToolSafetyManager (
135+ config . requireToolConfirmation ?? true ,
136+ config . toolExecutionTimeout ,
137+ config . toolOutputMaxChars
138+ ) ;
139+ this . orchestrator = new ToolOrchestrator ( this . toolRegistry , safetyManager , {
140+ loopProtection : {
141+ maxIterations : config . maxIterations ,
142+ maxToolCalls : config . maxToolCalls ,
143+ maxRepeatedCalls : config . maxRepeatedCalls ,
144+ } ,
145+ retryBudget : config . retryBudget ,
146+ } ) ;
120147
121148 this . promptBuilder = new AIAgentPromptBuilder ( ) ;
122- this . conversationManager = new ConversationManager ( ) ;
149+ this . conversationManager = new ConversationManager ( config . compressionThreshold ) ;
123150 }
124151
125152 async processQuery (
@@ -179,7 +206,7 @@ export class AIAgentCore {
179206 textMessage ( m . role as 'user' | 'assistant' , m . content )
180207 ) ;
181208
182- const maskResult = maskObservations ( messages ) ;
209+ const maskResult = maskObservations ( messages , this . observationMaskingOptions ) ;
183210 if ( maskResult . masked ) {
184211 getLogger ( ) . info (
185212 `AIAgentCore: observation masking applied maskedParts=${ maskResult . stats . maskedParts } savedTokens=${ maskResult . stats . savedTokens } buildUuid=${ context . buildUuid } `
0 commit comments