File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
dotnet/src/Connectors/Connectors.Google Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -381,6 +381,11 @@ public static GeminiPromptExecutionSettings FromExecutionSettings(PromptExecutio
381381 return settings ;
382382 }
383383
384+ /// <summary>
385+ /// Shared empty kernel instance used for FunctionChoiceBehavior conversion.
386+ /// </summary>
387+ private static readonly Kernel s_emptyKernel = new ( ) ;
388+
384389 /// <summary>
385390 /// Converts a <see cref="FunctionChoiceBehavior"/> to a <see cref="GeminiToolCallBehavior"/>.
386391 /// </summary>
@@ -393,20 +398,14 @@ public static GeminiPromptExecutionSettings FromExecutionSettings(PromptExecutio
393398 return null ;
394399 }
395400
396- // Static empty kernel to avoid creating new instances for each conversion
397- static Kernel GetEmptyKernel ( )
398- {
399- return new Kernel ( ) ;
400- }
401-
402401 // Check the type and determine auto-invoke by reflection or known behavior types
403402 // All FunctionChoiceBehavior types (Auto, Required, None) support auto-invoke
404403 // We use a simple approach: get the configuration with minimal context to check AutoInvoke
405404 try
406405 {
407406 var context = new FunctionChoiceBehaviorConfigurationContext ( new ChatHistory ( ) )
408407 {
409- Kernel = GetEmptyKernel ( ) , // Provide an empty kernel for the configuration
408+ Kernel = s_emptyKernel , // Provide an empty kernel for the configuration
410409 RequestSequenceIndex = 0
411410 } ;
412411 var config = functionChoiceBehavior . GetConfiguration ( context ) ;
You can’t perform that action at this time.
0 commit comments