Skip to content

.NET: feat(Agent Skill Scripts): bubble up error details#6309

Open
tlecomte wants to merge 2 commits into
microsoft:mainfrom
tlecomte:agent-skill-script-errors
Open

.NET: feat(Agent Skill Scripts): bubble up error details#6309
tlecomte wants to merge 2 commits into
microsoft:mainfrom
tlecomte:agent-skill-script-errors

Conversation

@tlecomte
Copy link
Copy Markdown

@tlecomte tlecomte commented Jun 3, 2026

Motivation and Context

Fixes #6304

AgentSkillsProvider provides a run_skill_script tool, 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#L1269

run_skill_script is adjusted to rethrow errors rather than swallowing them, so that users have the opportunity to choose to turn on FunctionInvokingChatClient.IncludeDetailedErrors and have the LLM self-correct its errors.

We believe it's not a breaking change, since FunctionInvokingChatClient.IncludeDetailedErrors defaults to false.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Copilot AI review requested due to automatic review settings June 3, 2026 14:32
@moonbox3 moonbox3 added the .NET label Jun 3, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AgentSkillsProvider to 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;
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pre-existing pattern used 7 other times in this file

@github-actions github-actions Bot changed the title feat(Agent Skill Scripts): bubble up error details .NET: feat(Agent Skill Scripts): bubble up error details Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [Feature]: Agent Skill Script error details are not bubbled up to the agent

3 participants