siyuan-note/siyuan · error

skill resource exceeds the %d byte limit: %s/%s

Error message

skill resource exceeds the %d byte limit: %s/%s

What it means

Skill resources are size-capped at maxSkillResourceBytes to keep agent context and memory bounded. readSkillResource stats the target and returns this error when the file exceeds the limit, before opening it.

Source

Thrown at kernel/util/skill.go:375

	if err != nil {
		return "", fmt.Errorf("skill not found: %s", skillName)
	}

	target := filepath.Join(realRoot, filepath.FromSlash(resource))
	realTarget, err := filepath.EvalSymlinks(target)
	if err != nil {
		return "", fmt.Errorf("skill resource not found: %s/%s", skillName, resource)
	}
	if realTarget != realRoot && !gulu.File.IsSubPath(realRoot, realTarget) {
		return "", fmt.Errorf("skill resource escapes skill directory: %s", resource)
	}

	info, err := os.Stat(realTarget)
	if err != nil || !info.Mode().IsRegular() {
		return "", fmt.Errorf("skill resource is not a regular file: %s/%s", skillName, resource)
	}
	if info.Size() > maxSkillResourceBytes {
		return "", fmt.Errorf("skill resource exceeds the %d byte limit: %s/%s", maxSkillResourceBytes, skillName, resource)
	}

	file, err := os.Open(realTarget)
	if err != nil {
		return "", fmt.Errorf("skill resource not found: %s/%s", skillName, resource)
	}
	defer file.Close()
	data, err := io.ReadAll(io.LimitReader(file, maxSkillResourceBytes+1))
	if err != nil {
		return "", fmt.Errorf("skill resource read failed: %s/%s", skillName, resource)
	}
	if len(data) > maxSkillResourceBytes {
		return "", fmt.Errorf("skill resource exceeds the %d byte limit: %s/%s", maxSkillResourceBytes, skillName, resource)
	}
	if !utf8.Valid(data) {
		return "", fmt.Errorf("skill resource is not valid UTF-8: %s/%s", skillName, resource)
	}
	return string(data), nil

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Move the large file out of the skill directory and reference it by external path in the skill body instead
  2. Split or compress the resource so each file is under the byte limit
  3. Trim the resource to the relevant excerpt needed by the agent
  4. If the content genuinely must be in-skill, restructure into multiple smaller resources

Example fix

// before
resources:
  - assets/full-dataset.csv  # 200 MB
// after
resources:
  - assets/dataset-sample.csv  # few KB excerpt
Defensive patterns

Strategy: validation

Validate before calling

const stat = require("fs").statSync(p.join(skillDir, resource));
if (stat.size > MAX_SKILL_RESOURCE_BYTES) {
  console.warn("resource too large; link externally instead");
}

Try / catch

try {
  return readSkillResource(dir, name, res);
} catch (e) {
  if (String(e).includes("byte limit")) {
    return readExcerptOnly(p.join(dir, res)); // read a bounded slice instead
  }
  throw e;
}

Prevention

When it happens

Trigger: Loading a skill resource whose file size is greater than maxSkillResourceBytes — e.g. a large PDF, dataset, or log file placed inside a skill directory and referenced as a resource.

Common situations: User drops large reference documents or media into a skill folder and links them as resources; generated files (logs, exports) accumulated inside the skill directory over time.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/48ac827d09d1ebe7. Report an issue: GitHub.