Skip to content

Commit 0bdffcd

Browse files
.Net: Fix for Stepwise Planner (#3088)
### 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. --> Resolves: #3085 This PR contains changes to handle complex result in StepwisePlanner action by adding type converter. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> 1. Added type converter in StepwisePlanner action result processing. 2. Enabled integration test for StepwisePlanner. ### 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 😄 Co-authored-by: Lee Miller <[email protected]>
1 parent ee4fb0d commit 0bdffcd

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎dotnet/src/IntegrationTests/Planners/StepwisePlanner/StepwisePlannerTests.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public async Task ExecutePlanFailsWithTooManyFunctionsAsync()
120120
Assert.Equal("ChatHistory is too long to get a completion. Try reducing the available functions.", ex.Message);
121121
}
122122

123-
[Fact(Skip = "Temporary skip this test.")]
123+
[Fact]
124124
public async Task ExecutePlanSucceedsWithAlmostTooManyFunctionsAsync()
125125
{
126126
// Arrange

‎dotnet/src/Planners/Planners.Core/Stepwise/StepwisePlanner.cs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,18 @@ protected internal virtual SystemStep ParseResult(string input)
528528

529529
try
530530
{
531+
string? result = null;
532+
531533
var vars = this.CreateActionContextVariables(actionVariables);
532534
var kernelResult = await this._kernel.RunAsync(targetFunction, vars, cancellationToken).ConfigureAwait(false);
533-
var result = kernelResult.GetValue<string>();
535+
var resultObject = kernelResult.GetValue<object>();
536+
537+
var converter = TypeDescriptor.GetConverter(resultObject);
538+
539+
if (converter.CanConvertTo(typeof(string)))
540+
{
541+
result = converter.ConvertToString(resultObject);
542+
}
534543

535544
this._logger?.LogTrace("Invoked {FunctionName}. Result: {Result}", targetFunction.Name, result);
536545

0 commit comments

Comments
 (0)