@@ -19,7 +19,6 @@ import { IEditLogService } from '../../../platform/multiFileEdit/common/editLogS
1919import { CUSTOM_TOOL_SEARCH_NAME , isAnthropicCustomToolSearchEnabled , isAnthropicToolSearchEnabled } from '../../../platform/networking/common/anthropic' ;
2020import { IChatEndpoint } from '../../../platform/networking/common/networking' ;
2121import { modelsWithoutResponsesContextManagement } from '../../../platform/networking/common/openai' ;
22- import { IToolDeferralService } from '../../../platform/networking/common/toolDeferralService' ;
2322import { INotebookService } from '../../../platform/notebook/common/notebookService' ;
2423import { GenAiMetrics } from '../../../platform/otel/common/genAiMetrics' ;
2524import { IOTelService } from '../../../platform/otel/common/otelService' ;
@@ -379,7 +378,6 @@ export class AgentIntentInvocation extends EditCodeIntentInvocation implements I
379378 @IExperimentationService private readonly expService : IExperimentationService ,
380379 @IAutomodeService private readonly automodeService : IAutomodeService ,
381380 @IOTelService override readonly otelService : IOTelService ,
382- @IToolDeferralService private readonly toolDeferralService : IToolDeferralService ,
383381 ) {
384382 super ( intent , location , endpoint , request , intentOptions , instantiationService , codeMapperService , envService , promptPathRepresentationService , endpointProvider , workspaceService , toolsService , configurationService , editLogService , commandService , telemetryService , notebookService , otelService ) ;
385383 }
@@ -405,15 +403,8 @@ export class AgentIntentInvocation extends EditCodeIntentInvocation implements I
405403 }
406404
407405 const tools = promptContext . tools ?. availableTools ;
408- // When Anthropic tool search is enabled, deferred tools are sent with
409- // defer_loading: true and don't count against the context window until
410- // the model loads them via tool_search. Only count non-deferred tools
411- // so the budget isn't artificially reduced.
412406 const toolSearchEnabled = isAnthropicToolSearchEnabled ( this . endpoint , this . configurationService ) ;
413- const effectiveTools = tools && toolSearchEnabled
414- ? tools . filter ( t => this . toolDeferralService . isNonDeferredTool ( t . name ) )
415- : tools ;
416- const toolTokens = effectiveTools ?. length ? await this . endpoint . acquireTokenizer ( ) . countToolTokens ( effectiveTools ) : 0 ;
407+ const toolTokens = tools ?. length ? await this . endpoint . acquireTokenizer ( ) . countToolTokens ( tools ) : 0 ;
417408
418409 const summarizeThresholdOverride = this . configurationService . getConfig < number | undefined > ( ConfigKey . Advanced . SummarizeAgentConversationHistoryThreshold ) ;
419410 if ( typeof summarizeThresholdOverride === 'number' && summarizeThresholdOverride < 100 && summarizeThresholdOverride > 0 ) {
@@ -441,7 +432,7 @@ export class AgentIntentInvocation extends EditCodeIntentInvocation implements I
441432 const safeBudget = useTruncation ? Number . MAX_SAFE_INTEGER : messageBudget ;
442433 const endpoint = toolTokens > 0 ? this . endpoint . cloneWithTokenOverride ( safeBudget ) : this . endpoint ;
443434
444- this . logService . debug ( `AgentIntent: rendering with budget=${ safeBudget } (baseBudget: ${ baseBudget } , toolTokens: ${ toolTokens } ${ toolSearchEnabled ? ` , totalTools: ${ tools ?. length ?? 0 } , nonDeferredTools : ${ effectiveTools ?. length ?? 0 } ` : '' } ), summarizationEnabled=${ summarizationEnabled } ` ) ;
435+ this . logService . debug ( `AgentIntent: rendering with budget=${ safeBudget } (baseBudget: ${ baseBudget } , toolTokens: ${ toolTokens } , totalTools: ${ tools ?. length ?? 0 } , toolSearchEnabled : ${ toolSearchEnabled } ), summarizationEnabled=${ summarizationEnabled } ` ) ;
445436 let result : RenderPromptResult ;
446437 const props : AgentPromptProps = {
447438 endpoint,
@@ -595,7 +586,7 @@ export class AgentIntentInvocation extends EditCodeIntentInvocation implements I
595586 const renderer = PromptRenderer . create ( this . instantiationService , this . endpoint , this . prompt , {
596587 ...renderProps ,
597588 endpoint : this . endpoint ,
598- promptContext : this . _buildSummarizationPromptContext ( renderProps . promptContext ) ,
589+ promptContext : renderProps . promptContext ,
599590 triggerSummarize : true ,
600591 } ) ;
601592 return await renderer . render ( progress , token ) ;
@@ -868,7 +859,7 @@ export class AgentIntentInvocation extends EditCodeIntentInvocation implements I
868859 const bgRenderer = PromptRenderer . create ( this . instantiationService , this . endpoint , this . prompt , {
869860 ...snapshotProps ,
870861 endpoint : this . endpoint ,
871- promptContext : this . _buildSummarizationPromptContext ( snapshotProps . promptContext ) ,
862+ promptContext : snapshotProps . promptContext ,
872863 triggerSummarize : true ,
873864 summarizationSource : 'background' ,
874865 } ) ;
@@ -978,30 +969,6 @@ export class AgentIntentInvocation extends EditCodeIntentInvocation implements I
978969 ) ) ;
979970 }
980971
981- /**
982- * Build a promptContext for summarization that filters availableTools to
983- * non-deferred tools when Anthropic tool search is enabled. Deferred tool
984- * schemas are unnecessary in the summarization prompt (which uses
985- * tool_choice: 'none') and can push the prompt over the token budget.
986- */
987- private _buildSummarizationPromptContext ( promptContext : IBuildPromptContext ) : IBuildPromptContext {
988- if ( ! promptContext . tools ?. availableTools ) {
989- return promptContext ;
990- }
991- const toolSearchEnabled = isAnthropicToolSearchEnabled ( this . endpoint , this . configurationService ) ;
992- if ( ! toolSearchEnabled ) {
993- return promptContext ;
994- }
995- const nonDeferredTools = promptContext . tools . availableTools . filter ( t => this . toolDeferralService . isNonDeferredTool ( t . name ) ) ;
996- return {
997- ...promptContext ,
998- tools : {
999- ...promptContext . tools ,
1000- availableTools : nonDeferredTools ,
1001- } ,
1002- } ;
1003- }
1004-
1005972 /**
1006973 * Record a background compaction failure on the current turn's metadata,
1007974 * matching how foreground compaction records its failures.
0 commit comments