Skip to content

Python: [BREAKING] Support code-defined agent skills#4387

Merged
SergeyMenshykh merged 10 commits intomicrosoft:mainfrom
SergeyMenshykh:support-code-skills
Mar 4, 2026
Merged

Python: [BREAKING] Support code-defined agent skills#4387
SergeyMenshykh merged 10 commits intomicrosoft:mainfrom
SergeyMenshykh:support-code-skills

Conversation

@SergeyMenshykh
Copy link
Member

@SergeyMenshykh SergeyMenshykh commented Mar 2, 2026

Summary

Adds support for code-defined agent skills — skills defined entirely in Python code using AgentSkill and AgentSkillResource classes, complementing the existing file-based SKILL.md approach.

Changes

Core (packages/core/agent_framework/_skills/)

  • Refactored single _skills.py module into a _skills/ package:
    • _models.pyAgentSkill and AgentSkillResource data model classes
    • _agent_skills_provider.pyAgentSkillsProvider (renamed from FileAgentSkillsProvider) supporting both file-based and code-defined skills
    • __init__.py — public API exports
  • AgentSkillsProvider now accepts a skills parameter for code-defined AgentSkill instances
  • AgentSkill.resource decorator for attaching dynamic callable resources
  • Removed backtick-quoted text matching for resource references; file-based resources are now discovered by scanning the skill directory for files with matching extensions

Samples

  • Added code_skill sample demonstrating two patterns:
    1. Basic code skill with static resources
    2. Dynamic resources via @skill.resource decorator
  • Fixed basic_skill/README.md incorrect directory/file names
  • Fixed basic_skill/basic_skill.py Example 2 to be genuinely multi-turn

Tests

  • Comprehensive test coverage for code-defined skills, combined file+code scenarios, XML formatting, validation, and resource reading

Related Issues

Copilot AI review requested due to automatic review settings March 2, 2026 12:05
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation python labels Mar 2, 2026
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Mar 2, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _skills.py285897%563, 602–603, 676, 681, 833–834, 1044
TOTAL22313275487% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
4836 247 💤 0 ❌ 0 🔥 1m 16s ⏱️

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

Adds Python support for code-defined agent skills, enabling skills to be declared in code (with optional dynamic resources) alongside existing file-based SKILL.md discovery.

Changes:

  • Refactors skills support into agent_framework._skills package with new AgentSkill, AgentSkillResource, and AgentSkillsProvider.
  • Extends the skills provider to register code-defined skills and expose dynamic resources via @skill.resource.
  • Updates samples and expands core test coverage to include code-defined skills and combined scenarios.

Reviewed changes

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

Show a summary per file
File Description
python/packages/core/agent_framework/_skills/_agent_skills_provider.py New unified provider for file-based + code-defined skills, discovery helpers, prompt/tool wiring.
python/packages/core/agent_framework/_skills/_models.py Introduces AgentSkill / AgentSkillResource models and @skill.resource decorator support.
python/packages/core/agent_framework/_skills/init.py Exposes the new public skills API from the package.
python/packages/core/agent_framework/init.py Updates public exports to the new skills API and removes the old provider export.
python/packages/core/tests/core/test_skills.py Expands tests to cover code-defined skills, combined scenarios, formatting, discovery, and validation.
python/samples/02-agents/skills/basic_skill/basic_skill.py Updates sample to use AgentSkillsProvider instead of the old provider.
python/samples/02-agents/skills/basic_skill/README.md Fixes sample structure/run command and updates provider naming.
python/samples/02-agents/skills/code_skill/code_skill.py Adds new sample demonstrating code-defined skills and dynamic resources.
python/samples/02-agents/skills/code_skill/README.md Documents the new code-defined skills sample.
python/packages/core/agent_framework/_skills.py Removes the legacy monolithic skills module in favor of the package layout.

@SergeyMenshykh SergeyMenshykh self-assigned this Mar 2, 2026
@SergeyMenshykh SergeyMenshykh moved this to In Review in Agent Framework Mar 2, 2026
@SergeyMenshykh SergeyMenshykh changed the title Python: Support code-defined agent skills Python: [BREAKING] Support code-defined agent skills Mar 2, 2026
@SergeyMenshykh SergeyMenshykh enabled auto-merge March 2, 2026 16:58
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Mar 4, 2026
Merged via the queue into microsoft:main with commit 4dad26f Mar 4, 2026
30 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in Agent Framework Mar 4, 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.

Python: FileAgentSkillsProvider incorrectly treats backtick-quoted text in SKILL.md as resource references

6 participants