Python: fix: stop treating backtick-quoted paths as resource references in Fi…#4382
Python: fix: stop treating backtick-quoted paths as resource references in Fi…#4382max-montes wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…leAgentSkillsProvider Backtick-quoted filenames in SKILL.md bodies (e.g. `config.json`) were incorrectly treated as resource file references by _RESOURCE_LINK_RE. When those files did not exist in the skill directory, the entire skill was excluded with a warning. Backticks are standard markdown inline code formatting and do not imply the referenced file exists locally. Only explicit markdown links ([text](path)) should be validated as resource references. Changes: - Update _RESOURCE_LINK_RE regex to match only markdown link syntax - Update tests to verify backtick paths are ignored - Add integration test for the reported scenario (issue microsoft#4369) Fixes microsoft#4369 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue in the Python FileAgentSkillsProvider where backtick-quoted filenames in SKILL.md (inline code formatting like `config.json`) were incorrectly treated as resource references and could cause the entire skill to be excluded if the referenced files didn’t exist. The change narrows resource detection to explicit Markdown link syntax only, aligning behavior with standard Markdown semantics and resolving issue #4369.
Changes:
- Update
_RESOURCE_LINK_REto match only Markdown links ([text](path/file.ext)) and stop extracting backtick-quoted paths as resources. - Update unit tests for
_extract_resource_pathsto ensure backtick-quoted filenames are ignored while Markdown links are still extracted. - Add an integration-level test ensuring skills still load when
SKILL.mdcontains non-existent backtick-quoted filenames, as long as linked resources are valid.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| python/packages/core/agent_framework/_skills.py | Restricts resource extraction to Markdown link syntax by removing backtick matching from _RESOURCE_LINK_RE. |
| python/packages/core/tests/core/test_skills.py | Updates existing tests to reflect new extraction rules and adds coverage for the reported scenario (issue #4369). |
@microsoft-github-policy-service agree |
|
Closing this in favor of #4387, which restructures the skills module and addresses the backtick parsing issue as part of a broader refactor. Happy to help review or test if useful! |
fix: Stop treating backtick-quoted paths as resource references in
FileAgentSkillsProvider
Backtick-quoted filenames in SKILL.md bodies (e.g.
config.json) were incorrectlytreated as resource file references by _RESOURCE_LINK_RE. When those files did not
exist in the skill directory, the entire skill was excluded with a warning.
Backticks are standard markdown inline code formatting and do not imply the referenced
file exists locally. Only explicit markdown links [text](path) should be validated
as resource references.
Changes:
Fixes #4369
Motivation and Context
FileAgentSkillsProviderincorrectly treats backtick-quoted filenames (e.g.config.json) in SKILL.md as resource file references. When those files don't exist inthe skill directory, the entire skill is excluded. This makes it impossible to use
standard markdown inline code formatting to mention filenames in skill documentation
without also providing those files on disk. Fixes #4369.
Description
Updated
_RESOURCE_LINK_REto only match explicit markdown link syntax(
[text](path/file.ext)), removing the backtick alternative. Backticks are standardmarkdown code formatting and should not imply a file exists locally.
Updated two existing tests to reflect the new behavior and added an integration-level
test that verifies a skill with backtick-quoted filenames (that don't exist on disk)
still loads successfully.
Note: The .NET implementation has the same regex in
FileAgentSkillLoader.cs(line 48) and is affected by the same bug. Will open a separate issue for the .NET fix
after this PR lands.
Contribution Checklist
Guidelines
backtick-quoted paths to register resources will need to switch to markdown link syntax
(
[text](path)). Pre-GA.