Skip to content

Commit b40e0cc

Browse files
malandismoonbox3
andauthored
.Net: fix: add "status" field to Python dynamic session response (microsoft#9903)
### Motivation and Context Addresses issue microsoft#9902 for .NET. Include the "status" field in the response string returned by Python dynamic sessions. Fixes a usability issue where the LLM assumes success despite execution failures. ### Description As per microsoft#9902, including the `status` property from the response in the plugin result, we ensure that the LLM has explicit information about whether the execution succeeded or failed, preventing misinterpretation of stderr or other response elements. This helps avoid hallucinated follow-ups or unnecessary retries by providing clear success/failure indicators. ### 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: Evan Mattson <[email protected]>
1 parent c2895a3 commit b40e0cc

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

dotnet/src/Plugins/Plugins.Core/CodeInterpreter/SessionsPythonPlugin.cs

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ public async Task<string> ExecuteCodeAsync([Description("The valid Python code t
113113
var jsonElementResult = JsonSerializer.Deserialize<JsonElement>(await response.Content.ReadAsStringAsync().ConfigureAwait(false));
114114

115115
return $"""
116+
Status:
117+
{jsonElementResult.GetProperty("status").GetRawText()}
116118
Result:
117119
{jsonElementResult.GetProperty("result").GetRawText()}
118120
Stdout:

dotnet/src/Plugins/Plugins.UnitTests/Core/SessionsPythonPluginTests.cs

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public async Task ItShouldExecuteCodeAsync()
7070
Content = new StringContent(responseContent),
7171
};
7272
var expectedResult = """
73+
Status:
74+
"Success"
7375
Result:
7476
""
7577
Stdout:

0 commit comments

Comments
 (0)