Skip to content

Python: [Bug]: FileAgentSkillsProvider mis-detects resource paths and excludes valid skills #4441

@claude89757

Description

@claude89757

Description

FileAgentSkillsProvider currently extracts resource paths from the full SKILL body using a broad regex, then hard-fails the entire skill when any extracted "resource" does not exist.

This creates false positives and makes valid skills unavailable.

What happens:

  1. Content inside fenced code blocks is scanned and matched as resource paths.
  2. Backtick matching is too permissive (tokens like tcp.seq_raw are treated as file paths).
  3. If any extracted path does not exist, the whole skill is excluded.

What I expected:

  • Ignore fenced code blocks when extracting resource paths.
  • For backtick paths, only treat as resource path when it looks like a path (at least contains /).
  • Missing resources should be non-fatal (warning), so the skill can still load; keep hard-fail for traversal/symlink security checks.

Steps to reproduce:

  1. Create a skill folder with a valid SKILL.md frontmatter (name, description).
  2. In the body, include a fenced code block containing dcx.json or protocol-like tokens such as tcp.seq_raw.
  3. Instantiate FileAgentSkillsProvider(skill_paths=...).
  4. Observe that skill loading excludes this skill because non-existent "resources" were extracted from markdown content that should not be treated as resource links.

Code Sample

from pathlib import Path
from tempfile import TemporaryDirectory

from agent_framework import FileAgentSkillsProvider

with TemporaryDirectory() as d:
    root = Path(d)
    skill_dir = root / "packet-inspector"
    skill_dir.mkdir(parents=True, exist_ok=True)

    (skill_dir / "SKILL.md").write_text(
        """---
name: packet-inspector
description: Analyze packet captures.
---
Use this field: `tcp.seq_raw`

```json
{ "example": "dcx.json" }

See reference.
""",
encoding="utf-8",
)

(skill_dir / "refs").mkdir(exist_ok=True)
(skill_dir / "refs" / "guide.md").write_text("ok", encoding="utf-8")

provider = FileAgentSkillsProvider(str(root))
# expected: skill is loaded
# actual: skill may be excluded due to false-positive resource extraction

### Error Messages / Stack Traces
Typical warning observed during load:

```text
Excluding skill '<skill-name>': referenced resource '<token>' does not exist

Package Versions

agent-framework-core: latest main (reproduced from current repository implementation)

Python Version

Python 3.11+

Additional Context

Current implementation points (Python):

  • python/packages/core/agent_framework/_skills.py
    • _extract_resource_paths() scans entire body with _RESOURCE_LINK_RE
    • _validate_resources() returns False on first missing resource

Suggested fix direction:

  • Strip fenced code blocks before resource extraction.
  • Tighten backtick path detection (require / in backtick candidate).
  • Treat missing resources as warning-only (do not exclude skill), while keeping path-traversal/symlink violations as exclusion conditions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions