Skip to content

[dotnet-code] Clarify file script run internals #499

Description

@github-actions

Summary

Extracted the file-backed script run closure into small unexported helpers. This keeps the Go file-skill script execution shape closer to the .NET AgentFileSkillScript.RunAsync guard sequence while preserving the existing public API and behavior.

.NET Reference

  • dotnet/src/Microsoft.Agents.AI/Skills/File/AgentFileSkillScript.cs - validates the owning file skill, checks for a configured runner, then invokes the file script runner.

Public API and Behavior

No public Go API changed. No intentional behavior change was made.

Tests

  • go test ./agent/skills/...
  • gofmt -w agent/skills/fsskills/source.go

Notes

Rejected candidates:

  • dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentInlineSkillResource.cs - Go inline skills are represented directly by skills.Skill values and test helpers rather than a corresponding internal resource type, so there was no narrow production cleanup to make.
  • dotnet/src/Microsoft.Agents.AI/Evaluation/ExpectedToolCall.cs - no matching Go evaluation surface was present in the sampled implementation, so changing Go would risk adding a missing feature rather than refactoring existing internals.
  • dotnet/src/Microsoft.Agents.AI.Workflows/ExternalResponse.cs - the close Go equivalent would require adding exported convenience methods to workflow.ExternalResponse, which would change the public Go API and violate the task constraints.

Open [dotnet-code] PRs were checked before editing; the existing workflow edge PR does not cover this file-skill script candidate.

Generated by .NET-to-Go Code Portability Refactoring Agent · 277 AIC · ⌖ 41.7 AIC · ⊞ 20.8K ·


Note

This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch dotnet-code-file-script-runner-d69ce61f4bcf05e1.

Click here to create the pull request

To fix the permissions issue, go to SettingsActionsGeneral and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ

Show patch preview (62 of 62 lines)
From a367d6b85d55ca8b8782c9c3e4fe5c257cc4cdd8 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Wed, 15 Jul 2026 22:41:31 +0000
Subject: [PATCH] Clarify file script run internals

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 agent/skills/fsskills/source.go | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/agent/skills/fsskills/source.go b/agent/skills/fsskills/source.go
index e3f30a12e..6cba2563d 100644
--- a/agent/skills/fsskills/source.go
+++ b/agent/skills/fsskills/source.go
@@ -540,22 +540,33 @@ func newScript(name string, fsys fs.FS, runner skills.ScriptRunner) skills.Scrip
 	return skills.Script{
 		Name:             name,
 		ParametersSchema: defaultFileScriptSchema,
-		Run: func(ctx context.Context, owner *skills.Skill, arguments []string) (any, error) {
-			if _, err := FSFromSkill(owner); err != nil {
-				return nil, fmt.Errorf("file-based script %q requires a skill with a backing fs.FS: %w", name, err)
-			}
-			if runner == nil {
-				return nil, fmt.Errorf("script %q cannot be executed because no file script runner was provided", name)
-			}
-			script := &skills.Script{Name: name}
-			return runner(ctx, owner, script, arguments)
-		},
+		Run:              newFileScriptRunFunc(name, runner),
 		AdditionalProperties: map[string]any{
 			"fsskills.scriptFS": fsys,
 		},
 	}
 }
 
+func newFileScriptRunFunc(name string, runner skills.ScriptRunner) func(context.Context, *skills.Skill, []string) (any, error) {
+	return func(ctx context.Context, owner *skills.Skill, arguments []string) (any, error) {
+		if err := requireFileSkill(name, owner); err != nil {
+			return nil, err
+		}
+		if runner == nil {
+			return nil, fmt.Errorf("script %q cannot be executed because no file script runner was provided", name)
+		}
+		script := &skills.Script{Name: name}
+		return runner(ctx, owner, script, arguments)
+	}
+}
+
+func requireFil
... (truncated)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions