Skip to content

Commit ad8c819

Browse files
authored
.Net Agents - Fix function result handling (#6927)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Empty function-result (`tool_output`) passed to assistant api. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> Change to utilize `FunctionResultContent` altered existing type assumption. Instead of handling a `FunctionResult`, only the `FunctionResult.Value` is now captured. Also updated sample method naming (opportunistic) ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄
1 parent 5d3cbed commit ad8c819

9 files changed

+9
-9
lines changed

dotnet/samples/GettingStartedWithAgents/Step1_Agent.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class Step1_Agent(ITestOutputHelper output) : BaseTest(output)
1515
private const string ParrotInstructions = "Repeat the user message in the voice of a pirate and then end with a parrot sound.";
1616

1717
[Fact]
18-
public async Task RunAsync()
18+
public async Task UseSingleChatCompletionAgentAsync()
1919
{
2020
// Define the agent
2121
ChatCompletionAgent agent =

dotnet/samples/GettingStartedWithAgents/Step2_Plugins.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class Step2_Plugins(ITestOutputHelper output) : BaseTest(output)
1717
private const string HostInstructions = "Answer questions about the menu.";
1818

1919
[Fact]
20-
public async Task RunAsync()
20+
public async Task UseChatCompletionWithPluginAgentAsync()
2121
{
2222
// Define the agent
2323
ChatCompletionAgent agent =

dotnet/samples/GettingStartedWithAgents/Step3_Chat.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Consider suggestions when refining an idea.
3434
""";
3535

3636
[Fact]
37-
public async Task RunAsync()
37+
public async Task UseAgentGroupChatWithTwoAgentsAsync()
3838
{
3939
// Define the agents
4040
ChatCompletionAgent agentReviewer =

dotnet/samples/GettingStartedWithAgents/Step4_KernelFunctionStrategies.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Consider suggestions when refining an idea.
3333
""";
3434

3535
[Fact]
36-
public async Task RunAsync()
36+
public async Task UseKernelFunctionStrategiesWithAgentGroupChatAsync()
3737
{
3838
// Define the agents
3939
ChatCompletionAgent agentReviewer =

dotnet/samples/GettingStartedWithAgents/Step5_JsonResult.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Think step-by-step and rate the user input on creativity and expressivness from
2828
""";
2929

3030
[Fact]
31-
public async Task RunAsync()
31+
public async Task UseKernelFunctionStrategiesWithJsonResultAsync()
3232
{
3333
// Define the agents
3434
ChatCompletionAgent agent =

dotnet/samples/GettingStartedWithAgents/Step6_DependencyInjection.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Think step-by-step and rate the user input on creativity and expressivness from
3030
""";
3131

3232
[Fact]
33-
public async Task RunAsync()
33+
public async Task UseDependencyInjectionToCreateAgentAsync()
3434
{
3535
ServiceCollection serviceContainer = new();
3636

dotnet/samples/GettingStartedWithAgents/Step7_Logging.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Consider suggestions when refining an idea.
3737
""";
3838

3939
[Fact]
40-
public async Task RunAsync()
40+
public async Task UseLoggerFactoryWithAgentGroupChatAsync()
4141
{
4242
// Define the agents
4343
ChatCompletionAgent agentReviewer =

dotnet/samples/GettingStartedWithAgents/Step8_OpenAIAssistant.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class Step8_OpenAIAssistant(ITestOutputHelper output) : BaseTest(output)
1818
private const string HostInstructions = "Answer questions about the menu.";
1919

2020
[Fact]
21-
public async Task RunAsync()
21+
public async Task UseSingleOpenAIAssistantAgentAsync()
2222
{
2323
// Define the agent
2424
OpenAIAssistantAgent agent =

dotnet/src/Agents/OpenAI/OpenAIAssistantChannel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ private static ToolOutput[] GenerateToolOutputs(FunctionResultContent[] function
456456
{
457457
FunctionResultContent functionResult = functionResults[index];
458458

459-
object resultValue = (functionResult.Result as FunctionResult)?.GetValue<object>() ?? string.Empty;
459+
object resultValue = functionResult.Result ?? string.Empty;
460460

461461
if (resultValue is not string textResult)
462462
{

0 commit comments

Comments
 (0)