in src/WebJobs.Extensions.OpenAI/Assistants/AssistantService.cs [373:403]
async Task ProcessSingleFunctionCall(
string assistantId,
ChatToolCall call,
InternalChatState chatState,
List<TableTransactionAction> batch,
CancellationToken cancellationToken)
{
this.logger.LogInformation(
"[{Id}] Calling function '{Name}' with arguments: {Args}",
assistantId,
call.FunctionName,
call.FunctionArguments);
string? functionResult = await this.InvokeFunctionWithErrorHandling(assistantId, call, cancellationToken);
if (string.IsNullOrWhiteSpace(functionResult))
{
functionResult = "The function call succeeded. Let the user know that you completed the action.";
}
ChatMessageTableEntity functionResultEntity = new(
partitionKey: assistantId,
messageIndex: ++chatState.Metadata.TotalMessages,
content: $"Function Name: '{call.FunctionName}' and Function Result: '{functionResult}'",
role: ChatMessageRole.Tool,
name: call.Id,
toolCalls: null);
chatState.Messages.Add(functionResultEntity);
batch.Add(new TableTransactionAction(TableTransactionActionType.Add, functionResultEntity));
}