.NET: feat(Agent Skill Scripts): bubble up error details#6309
Open
tlecomte wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates skill script execution error handling so executor exceptions propagate to callers (rather than being converted into a generic "Error: Failed to execute..." string), and adds a unit test to enforce that behavior.
Changes:
- Change
AgentSkillsProviderto rethrow script executor exceptions after logging. - Add a unit test asserting exceptions from the script executor bubble up through
run_skill_script.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI/Skills/AgentSkillsProvider.cs | Changes script execution failure handling from returning an error string to throwing the original exception. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentSkills/AgentSkillsProviderTests.cs | Adds a test validating exception propagation for run_skill_script. |
Comment on lines
357
to
361
| catch (Exception ex) | ||
| { | ||
| LogScriptExecutionError(this._logger, skillName, scriptName, ex); | ||
| return $"Error: Failed to execute script '{scriptName}' from skill '{skillName}'."; | ||
| throw; | ||
| } |
Author
There was a problem hiding this comment.
Happy to introduce SkillScriptExecutionException if we believe it's appropriate
Comment on lines
+738
to
+746
| var runScriptTool = result.Tools!.First(t => t.Name == "run_skill_script") as AIFunction; | ||
|
|
||
| // Act & Assert — exception must bubble up so the LLM can self-correct from the error details | ||
| var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => | ||
| runScriptTool!.InvokeAsync(new AIFunctionArguments(new Dictionary<string, object?> | ||
| { | ||
| ["skillName"] = "throw-script-skill", | ||
| ["scriptName"] = "scripts/run.py", | ||
| })).AsTask()); |
Author
There was a problem hiding this comment.
This is a pre-existing pattern used 7 other times in this file
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation and Context
Fixes #6304
AgentSkillsProviderprovides arun_skill_scripttool, whose implementation swallows exceptions and never returns the error details to the agent. This prevents the agent from self-correcting itself, because it does not know what failed.Description
In Microsoft.Extensions.AI, the behavior of tools regarding errors is configurable with
FunctionInvokingChatClient.IncludeDetailedErrors: https://github.com/dotnet/extensions/blob/d6451f303b4142f9e6b6706e901dc1e43d12933c/src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs#L1269run_skill_scriptis adjusted to rethrow errors rather than swallowing them, so that users have the opportunity to choose to turn onFunctionInvokingChatClient.IncludeDetailedErrorsand have the LLM self-correct its errors.We believe it's not a breaking change, since
FunctionInvokingChatClient.IncludeDetailedErrorsdefaults tofalse.Contribution Checklist