Skip to content

Python: Support Agent Skills#4210

Merged
SergeyMenshykh merged 17 commits intomicrosoft:mainfrom
SergeyMenshykh:python-support-agent-skills
Feb 25, 2026
Merged

Python: Support Agent Skills#4210
SergeyMenshykh merged 17 commits intomicrosoft:mainfrom
SergeyMenshykh:python-support-agent-skills

Conversation

@SergeyMenshykh
Copy link
Member

Summary

Adds FileAgentSkillsProvider, a BaseContextProvider that discovers and exposes Agent Skills from filesystem directories following the Agent Skills specification progressive disclosure pattern: advertise → load → read resources.

This is the Python counterpart of #4122 (.NET).

Changes

  • FileAgentSkillsProvider — discovers SKILL.md files from configured directories, advertises skills via system prompt injection, and provides load_skill / read_skill_resource tools for on-demand access.
  • Internal helpers for skill discovery, YAML frontmatter parsing, and secure resource reading (path traversal / symlink guards).
  • Unit tests (61 tests) covering discovery, loading, resource reading, security scenarios (path traversal, symlink escape, similar-prefix attacks), and edge cases.
  • Sample (basic_file_skills) demonstrating usage with an expense-report skill.

Key Design Decisions

  • Skills are read-only static content; no code execution.
  • XML-escaping for prompt injection safety.
  • Resource reads are guarded against path traversal and symlink escape.
  • Resource link regex matches both markdown links and backtick-quoted paths (aligned with .NET implementation).
  • Only skills from trusted sources should be used.

Out of Scope

  • Script execution, which will be added in a following PR.

Closes: #3499

Add FileAgentSkillsProvider, a context provider that discovers and exposes
Agent Skills from filesystem directories following the Agent Skills
specification (https://agentskills.io/) progressive disclosure pattern:
advertise, load, read resources.

Changes:
- FileAgentSkillsProvider - discovers SKILL.md files from configured
  directories, advertises skills via system prompt injection, and provides
  load_skill / read_skill_resource tools for on-demand access.
- Internal helpers for skill discovery, frontmatter parsing, and secure
  resource reading (path traversal / symlink guards).
- Unit tests covering discovery, loading, resource reading, and security
  scenarios.
- Sample (basic_file_skills) demonstrating usage with an expense-report skill.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 24, 2026 13:40
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation python labels Feb 24, 2026
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Feb 24, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _skills.py2251195%153–154, 167–168, 280–282, 317–318, 398, 582
TOTAL22033277587% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
4624 244 💤 0 ❌ 0 🔥 1m 19s ⏱️

Align sample directory name with .NET equivalent (Agent_Step01_BasicSkills).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Python support for the Agent Skills specification by implementing FileAgentSkillsProvider, a context provider that discovers and exposes skills from filesystem directories. This is the Python counterpart to the .NET implementation in PR #4122.

Changes:

  • Implements FileAgentSkillsProvider with progressive disclosure pattern (advertise → load → read resources)
  • Adds comprehensive security measures including path traversal and symlink guards
  • Includes 61 unit tests covering discovery, loading, resource reading, and security scenarios
  • Provides a sample demonstrating usage with an expense-report skill

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
python/packages/core/agent_framework/_skills.py Core implementation with skill discovery, YAML parsing, resource extraction, and security guards
python/packages/core/agent_framework/__init__.py Exports FileAgentSkillsProvider to public API
python/packages/core/tests/core/test_skills.py Comprehensive test suite with 61 tests covering functionality and security
python/samples/02-agents/context_providers/skills/basic_file_skills.py Sample demonstrating skill provider usage
python/samples/02-agents/context_providers/skills/skills/expense-report/SKILL.md Sample skill with expense policy rules
python/samples/02-agents/context_providers/skills/skills/expense-report/references/POLICY_FAQ.md FAQ resource for the expense-report skill
python/samples/02-agents/context_providers/skills/skills/expense-report/assets/expense-report-template.md Template asset for the expense-report skill
python/samples/02-agents/context_providers/skills/README.md Documentation for the skills sample

Copy link
Member

@eavanvalkenburg eavanvalkenburg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, some minor comments left!

@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Feb 25, 2026
Merged via the queue into microsoft:main with commit 4dc35e9 Feb 25, 2026
30 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in Agent Framework Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Support for Agent Skills

5 participants