Python: Forward runtime kwargs to skill resource functions#4417
Merged
SergeyMenshykh merged 13 commits intomicrosoft:mainfrom Mar 5, 2026
Merged
Conversation
Member
Contributor
There was a problem hiding this comment.
Pull request overview
This PR significantly refactors the Agent Skills system by: (1) replacing FileAgentSkillsProvider with a unified SkillsProvider that supports both file-based and code-defined skills, (2) introducing Skill and SkillResource classes as public API, and (3) enabling @skill.resource-decorated functions to receive runtime kwargs passed via agent.run(), matching the existing @tool kwargs pattern.
Changes:
- Core refactor of
_skills.py: replacesFileAgentSkillsProvider/_FileAgentSkillwithSkillsProvider/Skill/SkillResourceclasses; adds**kwargsforwarding to callable resource functions; changes resource discovery from markdown-link parsing to filesystem scanning - Comprehensive test rewrite in
test_skills.py: updates all existing tests for the new API and adds new test cases for code-defined skills, kwargs forwarding, and edge cases - New
code_skillsample and README demonstrating code-defined skills with dynamic resources and kwargs injection; updatesbasic_skillsample to use the renamedSkillsProvider
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
python/packages/core/agent_framework/_skills.py |
Full refactor: new Skill/SkillResource/SkillsProvider classes; kwargs forwarding in _read_skill_resource; filesystem-based resource discovery |
python/packages/core/agent_framework/__init__.py |
Exports Skill, SkillResource, SkillsProvider; removes FileAgentSkillsProvider |
python/packages/core/tests/core/test_skills.py |
Updated tests for new API + new tests for code-defined skills and kwargs |
python/samples/02-agents/skills/code_skill/code_skill.py |
New sample demonstrating three skill patterns including kwargs-enabled resources |
python/samples/02-agents/skills/code_skill/README.md |
Documentation for new code_skill sample |
python/samples/02-agents/skills/basic_skill/basic_skill.py |
Updated to use renamed SkillsProvider |
python/samples/02-agents/skills/basic_skill/README.md |
Updated references to SkillsProvider and corrected file/directory names |
eavanvalkenburg
approved these changes
Mar 5, 2026
giles17
approved these changes
Mar 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enables
@skill.resourcedecorated functions to receive runtime keyword arguments passed viaagent.run(), matching the existing@toolkwargs pattern.Problem
Currently, skill resource functions (decorated with
@skill.resource) are always called with zero arguments. In contrast, regular@toolfunctions can receive runtime kwargs passed viaagent.run(user_id="123")through**kwargs. This makes it impossible to inject request-scoped context (app version, auth tokens, correlation IDs) into skill resources.Changes
Core (
_skills.py)**kwargs: Anyto_read_skill_resource()method signature**kwargsviainspect.signature(same pattern asFunctionTool)**kwargsare unaffected (backward compatible)Tests (
test_skills.py)**kwargsstill works when extra args are passedSample (
code_skill.py)project_info_skill'senvironment()resource to accept**kwargsand useapp_versionmain()to passapp_version="2.4.1"viaagent.run()Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com