@@ -411,12 +411,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
411411 // Initialize the assistant message parser only for XML protocol.
412412 // For native protocol, tool calls come as tool_call chunks, not XML.
413413 // experiments is always provided via TaskOptions (defaults to experimentDefault in provider)
414- const toolProtocol = resolveToolProtocol (
415- this . apiConfiguration ,
416- this . api . getModel ( ) . info ,
417- this . apiConfiguration . apiProvider ,
418- experimentsConfig ,
419- )
414+ const toolProtocol = resolveToolProtocol ( this . apiConfiguration , this . api . getModel ( ) . info )
420415 this . assistantMessageParser = toolProtocol === "xml" ? new AssistantMessageParser ( ) : undefined
421416
422417 this . messageQueueService = new MessageQueueService ( )
@@ -1271,12 +1266,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
12711266 )
12721267 const modelInfo = this . api . getModel ( ) . info
12731268 const state = await this . providerRef . deref ( ) ?. getState ( )
1274- const toolProtocol = resolveToolProtocol (
1275- this . apiConfiguration ,
1276- modelInfo ,
1277- this . apiConfiguration . apiProvider ,
1278- state ?. experiments ,
1279- )
1269+ const toolProtocol = resolveToolProtocol ( this . apiConfiguration , modelInfo )
12801270 return formatResponse . toolError ( formatResponse . missingToolParameterError ( paramName , toolProtocol ) )
12811271 }
12821272
@@ -1420,12 +1410,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
14201410 // conversations with tool uses and no tool schema.
14211411 // For native protocol, we preserve tool_use and tool_result blocks as they're expected by the API.
14221412 const state = await this . providerRef . deref ( ) ?. getState ( )
1423- const protocol = resolveToolProtocol (
1424- this . apiConfiguration ,
1425- this . api . getModel ( ) . info ,
1426- this . apiConfiguration . apiProvider ,
1427- state ?. experiments ,
1428- )
1413+ const protocol = resolveToolProtocol ( this . apiConfiguration , this . api . getModel ( ) . info )
14291414 const useNative = isNativeProtocol ( protocol )
14301415
14311416 // Only convert tool blocks to text for XML protocol
@@ -1803,12 +1788,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
18031788 } else {
18041789 const modelInfo = this . api . getModel ( ) . info
18051790 const state = await this . providerRef . deref ( ) ?. getState ( )
1806- const toolProtocol = resolveToolProtocol (
1807- this . apiConfiguration ,
1808- modelInfo ,
1809- this . apiConfiguration . apiProvider ,
1810- state ?. experiments ,
1811- )
1791+ const toolProtocol = resolveToolProtocol ( this . apiConfiguration , modelInfo )
18121792 nextUserContent = [ { type : "text" , text : formatResponse . noToolsUsed ( toolProtocol ) } ]
18131793 this . consecutiveMistakeCount ++
18141794 }
@@ -2456,12 +2436,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
24562436 // Check if we're using native protocol
24572437 const state = await this . providerRef . deref ( ) ?. getState ( )
24582438 const isNative = isNativeProtocol (
2459- resolveToolProtocol (
2460- this . apiConfiguration ,
2461- this . api . getModel ( ) . info ,
2462- this . apiConfiguration . apiProvider ,
2463- state ?. experiments ,
2464- ) ,
2439+ resolveToolProtocol ( this . apiConfiguration , this . api . getModel ( ) . info ) ,
24652440 )
24662441
24672442 if ( isNative ) {
@@ -2602,12 +2577,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
26022577 if ( ! didToolUse ) {
26032578 const modelInfo = this . api . getModel ( ) . info
26042579 const state = await this . providerRef . deref ( ) ?. getState ( )
2605- const toolProtocol = resolveToolProtocol (
2606- this . apiConfiguration ,
2607- modelInfo ,
2608- this . apiConfiguration . apiProvider ,
2609- state ?. experiments ,
2610- )
2580+ const toolProtocol = resolveToolProtocol ( this . apiConfiguration , modelInfo )
26112581 this . userMessageContent . push ( { type : "text" , text : formatResponse . noToolsUsed ( toolProtocol ) } )
26122582 this . consecutiveMistakeCount ++
26132583 }
@@ -2634,14 +2604,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
26342604 // user messages (which would cause tool_result validation errors).
26352605 let state = await this . providerRef . deref ( ) ?. getState ( )
26362606 if (
2637- isNativeProtocol (
2638- resolveToolProtocol (
2639- this . apiConfiguration ,
2640- this . api . getModel ( ) . info ,
2641- this . apiConfiguration . apiProvider ,
2642- state ?. experiments ,
2643- ) ,
2644- ) &&
2607+ isNativeProtocol ( resolveToolProtocol ( this . apiConfiguration , this . api . getModel ( ) . info ) ) &&
26452608 this . apiConversationHistory . length > 0
26462609 ) {
26472610 const lastMessage = this . apiConversationHistory [ this . apiConversationHistory . length - 1 ]
@@ -2707,14 +2670,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
27072670 // For native protocol, re-add the user message we removed
27082671 // Reuse the state variable from above
27092672 if (
2710- isNativeProtocol (
2711- resolveToolProtocol (
2712- this . apiConfiguration ,
2713- this . api . getModel ( ) . info ,
2714- this . apiConfiguration . apiProvider ,
2715- state ?. experiments ,
2716- ) ,
2717- )
2673+ isNativeProtocol ( resolveToolProtocol ( this . apiConfiguration , this . api . getModel ( ) . info ) )
27182674 ) {
27192675 await this . addToApiConversationHistory ( {
27202676 role : "user" ,
@@ -2813,12 +2769,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
28132769 const canUseBrowserTool = modelSupportsBrowser && modeSupportsBrowser && ( browserToolEnabled ?? true )
28142770
28152771 // Resolve the tool protocol based on profile, model, and provider settings
2816- const toolProtocol = resolveToolProtocol (
2817- apiConfiguration ?? this . apiConfiguration ,
2818- modelInfo ,
2819- ( apiConfiguration ?? this . apiConfiguration ) ?. apiProvider ,
2820- experiments ,
2821- )
2772+ const toolProtocol = resolveToolProtocol ( apiConfiguration ?? this . apiConfiguration , modelInfo )
28222773
28232774 return SYSTEM_PROMPT (
28242775 provider . context ,
@@ -3057,12 +3008,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
30573008 // 1. Tool protocol is set to NATIVE
30583009 // 2. Model supports native tools
30593010 const modelInfo = this . api . getModel ( ) . info
3060- const toolProtocol = resolveToolProtocol (
3061- this . apiConfiguration ,
3062- modelInfo ,
3063- this . apiConfiguration . apiProvider ,
3064- state ?. experiments ,
3065- )
3011+ const toolProtocol = resolveToolProtocol ( this . apiConfiguration , modelInfo )
30663012 const shouldIncludeTools = toolProtocol === TOOL_PROTOCOL . NATIVE && ( modelInfo . supportsNativeTools ?? false )
30673013
30683014 // Build complete tools array: native tools + dynamic MCP tools, filtered by mode restrictions
0 commit comments