Tencent/WeKnora · error
failed to load script: %w
Error message
failed to load script: %w
What it means
buildSkillExecuteConfig wraps any error from source.LoadSkillFile when the skill is NOT installed in the sandbox image (preloaded/host skill). The underlying cause — missing file, unreadable path, archive error — is preserved via %w; this wrapper adds context that the script could not be loaded from the skill's host files.
Source
Thrown at internal/agent/skills/manager.go:449
// as WorkDir.
func buildSkillExecuteConfig(
source SkillSource,
skillName, scriptPath, basePath string,
args []string,
stdin string,
env map[string]string,
sessionID string,
) (*sandbox.ExecuteConfig, error) {
if workspace, ok := sandbox.RunnableWorkspaceScript(scriptPath); ok {
return workspaceSkillExecuteConfig(source, skillName, workspace, basePath, args, stdin, env, sessionID)
}
image, installed := source.(imageSkillSource)
if !installed {
// Load the script file to verify it exists and is a script
file, err := source.LoadSkillFile(skillName, scriptPath)
if err != nil {
return nil, fmt.Errorf("failed to load script: %w", err)
}
if !file.IsScript {
return nil, fmt.Errorf("file is not an executable script: %s", scriptPath)
}
return &sandbox.ExecuteConfig{
Script: file.Path,
Args: args,
WorkDir: basePath,
Stdin: stdin,
Env: env,
SessionID: sessionID,
}, nil
}
// The archive is deliberately not consulted: the image is what executes,
// and a skill whose archive failed to store is still installed and
// runnable. That leaves the extension as the only check available here,
// which is also the one the executor's interpreter choice depends on.View on GitHub (pinned to 988cbb0330)
Solutions
- Fix the underlying wrapped error shown after 'failed to load script:' — usually a wrong or missing script path relative to the skill root
- Check the skill directory contents (GetSkillInfo / ListSkillFiles) to confirm the script exists at the given relative path
- Re-upload/reinstall the skill if its archive is missing files
- Verify read permissions on the skill's host directory
Example fix
// before mgr.ExecuteScript(ctx, "pdf", "script/run.py", nil, "") // wrong dir // after mgr.ExecuteScript(ctx, "pdf", "scripts/run.py", nil, "") // matches skill layout
Defensive patterns
Strategy: validation
Validate before calling
files, err := mgr.ListSkillFiles(skillName)
if err != nil { return err }
if !slices.Contains(files, scriptPath) {
return fmt.Errorf("%s not present in skill %s", scriptPath, skillName)
} Type guard
func scriptExistsInSkill(m *skills.Manager, skill, path string) bool {
files, err := m.ListSkillFiles(skill)
if err != nil { return false }
return slices.Contains(files, path)
} Try / catch
cfg, err := mgr.ExecuteScript(ctx, skill, path, args, stdin)
if err != nil {
var wrapped interface{ Unwrap() error }
if strings.HasPrefix(err.Error(), "failed to load script:") {
log.Printf("script %s missing in skill %s: %v", path, skill, err)
}
return err
} Prevention
- Validate script paths against ListSkillFiles before executing
- Keep SKILL.md script references in sync with the shipped archive contents
- Use skill-relative paths exactly as listed by the skill metadata
- Re-upload skills after editing their file layout
When it happens
Trigger: Manager.ExecuteScript with a skill-relative scriptPath on a preloaded (non-image) skill where LoadSkillFile fails: the relative path does not exist in the skill directory, the path escapes the skill dir, or the skill's files are unreadable.
Common situations: Typo in the script path (e.g. script/run.py vs scripts/run.py); the SKILL.md references a script that was not shipped in the skill archive; filesystem permission problems on the host skill directory.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- sandbox: create input directory: %w
- sandbox: create workspace directory: %w
- storage directory not accessible: %w
- storage path is not a directory: %s
- failed to create directory: %w
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/b7486053fd3a3844.
Report an issue: GitHub.