-
-
Notifications
You must be signed in to change notification settings - Fork 647
revert #1424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+26
−14
Merged
revert #1424
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,15 +25,19 @@ private async Task<RoleDialogModel> InnerCreateResponse(Agent agent, List<RoleDi | |
| var response = await responsesClient.CreateResponseAsync(options); | ||
| var value = response.Value; | ||
|
|
||
| var functionCall = value.OutputItems.OfType<FunctionCallResponseItem>().FirstOrDefault(); | ||
| // Every call the model asked for, not only the first. It routinely asks for several | ||
| // independent ones at once, and keeping one made it re-ask for the rest next turn. | ||
| var functionCalls = value.OutputItems.OfType<FunctionCallResponseItem>().ToList(); | ||
| var toolCalls = ToLlmToolCalls(functionCalls); | ||
| var functionCall = functionCalls.FirstOrDefault(); | ||
| var reasoningItem = value.OutputItems.OfType<ReasoningResponseItem>().FirstOrDefault(); | ||
| var text = value.GetOutputText() ?? string.Empty; | ||
| var thinkingText = reasoningItem?.GetSummaryText(); | ||
|
|
||
| RoleDialogModel responseMessage; | ||
| if (functionCall != null) | ||
| { | ||
| _logger.LogInformation($"Action: {nameof(InnerCreateResponse)}, Agent: {agent.Name}, ToolCall: {functionCall.FunctionName}"); | ||
| _logger.LogInformation($"Action: {nameof(InnerCreateResponse)}, Agent: {agent.Name}, ToolCalls: {string.Join(",", toolCalls.Select(x => x.FunctionName))}"); | ||
|
|
||
| responseMessage = new RoleDialogModel(AgentRole.Function, text) | ||
| { | ||
|
|
@@ -42,6 +46,7 @@ private async Task<RoleDialogModel> InnerCreateResponse(Agent agent, List<RoleDi | |
| ToolCallId = functionCall.CallId, | ||
| FunctionName = functionCall.FunctionName.NormalizeFunctionName(), | ||
| FunctionArgs = functionCall.FunctionArguments?.ToString(), | ||
| ToolCalls = toolCalls, | ||
| RenderedInstruction = string.Join("\r\n", renderedInstructions) | ||
| }; | ||
| } | ||
|
|
@@ -113,15 +118,19 @@ private async Task<bool> InnerCreateResponseAsync(Agent agent, | |
| var response = await responsesClient.CreateResponseAsync(options); | ||
| var value = response.Value; | ||
|
|
||
| var functionCall = value.OutputItems.OfType<FunctionCallResponseItem>().FirstOrDefault(); | ||
| // Every call the model asked for, not only the first. It routinely asks for several | ||
| // independent ones at once, and keeping one made it re-ask for the rest next turn. | ||
| var functionCalls = value.OutputItems.OfType<FunctionCallResponseItem>().ToList(); | ||
| var toolCalls = ToLlmToolCalls(functionCalls); | ||
| var functionCall = functionCalls.FirstOrDefault(); | ||
| var reasoningItem = value.OutputItems.OfType<ReasoningResponseItem>().FirstOrDefault(); | ||
| var text = value.GetOutputText() ?? string.Empty; | ||
| var thinkingText = reasoningItem?.GetSummaryText(); | ||
|
|
||
| RoleDialogModel responseMessage; | ||
| if (functionCall != null) | ||
| { | ||
| _logger.LogInformation($"Action: {nameof(InnerCreateResponseAsync)}, Agent: {agent.Name}, ToolCall: {functionCall.FunctionName}"); | ||
| _logger.LogInformation($"Action: {nameof(InnerCreateResponseAsync)}, Agent: {agent.Name}, ToolCalls: {string.Join(",", toolCalls.Select(x => x.FunctionName))}"); | ||
|
|
||
| responseMessage = new RoleDialogModel(AgentRole.Function, text) | ||
| { | ||
|
|
@@ -130,6 +139,7 @@ private async Task<bool> InnerCreateResponseAsync(Agent agent, | |
| ToolCallId = functionCall.CallId, | ||
| FunctionName = functionCall.FunctionName.NormalizeFunctionName(), | ||
| FunctionArgs = functionCall.FunctionArguments?.ToString(), | ||
| ToolCalls = toolCalls, | ||
| RenderedInstruction = string.Join("\r\n", renderedInstructions) | ||
| }; | ||
| } | ||
|
|
@@ -221,7 +231,7 @@ private async Task<RoleDialogModel> InnerCreateResponseStreamingAsync(Agent agen | |
|
|
||
| using var textStream = new RealtimeTextStream(); | ||
| using var thinkingStream = new RealtimeTextStream(); | ||
| FunctionCallResponseItem? functionCall = null; | ||
| var functionCalls = new List<FunctionCallResponseItem>(); | ||
| ResponseResult? finalResult = null; | ||
| ResponseTokenUsage? tokenUsage = null; | ||
|
|
||
|
|
@@ -312,7 +322,7 @@ private async Task<RoleDialogModel> InnerCreateResponseStreamingAsync(Agent agen | |
| { | ||
| if (itemDone.Item is FunctionCallResponseItem fc) | ||
| { | ||
| functionCall = fc; | ||
| functionCalls.Add(fc); | ||
| #if DEBUG | ||
| _logger.LogDebug($"Tool Call (id: {fc.CallId}) => {fc.FunctionName}({fc.FunctionArguments})"); | ||
| #endif | ||
|
|
@@ -342,9 +352,12 @@ private async Task<RoleDialogModel> InnerCreateResponseStreamingAsync(Agent agen | |
| var allText = textStream.GetText(); | ||
| var thinkingText = thinkingStream.GetText(); | ||
|
|
||
| var toolCalls = ToLlmToolCalls(functionCalls); | ||
| var functionCall = functionCalls.FirstOrDefault(); | ||
|
|
||
| if (functionCall != null) | ||
| { | ||
| _logger.LogInformation($"Action: {nameof(InnerCreateResponseStreamingAsync)}, Agent: {agent.Name}, ToolCall: {functionCall.FunctionName}"); | ||
| _logger.LogInformation($"Action: {nameof(InnerCreateResponseStreamingAsync)}, Agent: {agent.Name}, ToolCalls: {string.Join(",", toolCalls.Select(x => x.FunctionName))}"); | ||
|
|
||
| responseMessage = new RoleDialogModel(AgentRole.Function, allText) | ||
| { | ||
|
|
@@ -353,6 +366,7 @@ private async Task<RoleDialogModel> InnerCreateResponseStreamingAsync(Agent agen | |
| ToolCallId = functionCall.CallId, | ||
| FunctionName = functionCall.FunctionName.NormalizeFunctionName(), | ||
| FunctionArgs = functionCall.FunctionArguments?.ToString(), | ||
| ToolCalls = toolCalls, | ||
| RenderedInstruction = string.Join("\r\n", renderedInstructions) | ||
| }; | ||
| } | ||
|
|
@@ -424,14 +438,12 @@ private async Task<RoleDialogModel> InnerCreateResponseStreamingAsync(Agent agen | |
| var allowMultiModal = settings != null && settings.MultiModal; | ||
| renderedInstructions = []; | ||
|
|
||
| float? temperature = float.Parse(_state.GetState("temperature", "0.0")); | ||
| var maxTokens = int.TryParse(_state.GetState("max_tokens"), out var tokens) | ||
| ? tokens | ||
| : agent.LlmConfig?.MaxOutputTokens ?? LlmConstant.DEFAULT_MAX_OUTPUT_TOKEN; | ||
|
|
||
| var options = new CreateResponseOptions(_model, []) | ||
| { | ||
| Temperature = temperature, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Responses temperature is ignored Removing CreateResponseOptions.Temperature causes every Responses API request to ignore the conversation's temperature state and use the SDK/API default instead. Configured deterministic or creative behavior therefore changes whenever UseResponseApi is enabled, while the Chat Completions path still honors the same state. Agent Prompt
|
||
| MaxOutputTokenCount = maxTokens, | ||
| }; | ||
|
|
||
|
|
@@ -444,11 +456,6 @@ private async Task<RoleDialogModel> InnerCreateResponseStreamingAsync(Agent agen | |
| ReasoningEffortLevel = reasoningEffortLevel.Value, | ||
| ReasoningSummaryVerbosity = ResponseReasoningSummaryVerbosity.Auto | ||
| }; | ||
|
|
||
| if (reasoningEffortLevel != ResponseReasoningEffortLevel.None) | ||
| { | ||
| options.Temperature = null; | ||
| } | ||
| } | ||
|
|
||
| // Response format | ||
|
|
@@ -822,4 +829,9 @@ private void SetResponseFormat(CreateResponseOptions options, AgentLlmConfig? ll | |
| } : null; | ||
| } | ||
| #endregion | ||
|
|
||
| private static List<LlmToolCall> ToLlmToolCalls(IEnumerable<FunctionCallResponseItem>? functionCalls) | ||
| => (functionCalls ?? []) | ||
| .Select(x => new LlmToolCall(x.CallId, x.FunctionName, x.FunctionArguments?.ToString())) | ||
| .ToList(); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Additional tool calls are dropped
🐞 Bug≡ CorrectnessAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools