Skip to content

Python: [Breaking] Refactor Skill API to async resource and script lookup#6135

Merged
semenshi merged 1 commit into
microsoft:mainfrom
semenshi:python/refactor-skill-async-api
May 28, 2026
Merged

Python: [Breaking] Refactor Skill API to async resource and script lookup#6135
semenshi merged 1 commit into
microsoft:mainfrom
semenshi:python/refactor-skill-async-api

Conversation

@semenshi
Copy link
Copy Markdown
Collaborator

Motivation and Context

Port of .NET commit 08541ee (.NET: [Breaking] Refactor AgentSkill API to async resource and script lookup #6030).

Description

Refactor Skill API from synchronous properties to async by-name lookup methods:

  • content property to async get_content() -> str
  • resources property to async get_resource(name) -> SkillResource | None
  • scripts property to async get_script(name) -> SkillScript | None

Each skill subclass owns its lookup. ClassSkill retains resources/scripts properties as overridable hooks.

SkillsProvider always includes all 3 tools and both instruction blocks regardless of whether skills have resources or scripts.

Contribution Checklist

  • Builds clean without errors or warnings
  • All unit tests pass
  • This is a breaking change

…okup

Port of .NET commit 08541ee.

Replace property-based Skill.content/resources/scripts with async
by-name lookup methods:
- content property -> async get_content() -> str
- resources property -> async get_resource(name) -> SkillResource | None
- scripts property -> async get_script(name) -> SkillScript | None

SkillsProvider now always includes all three tools (load_skill,
read_skill_resource, run_skill_script) and both instruction blocks
regardless of whether any skills have resources or scripts.

ClassSkill retains resources/scripts properties as overridable hooks
for subclass reflection-based discovery.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 28, 2026 09:48
@semenshi semenshi self-assigned this May 28, 2026
@semenshi semenshi moved this to In Review in Agent Framework May 28, 2026
Copy link
Copy Markdown
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 refactors the Python Skills API to use async content/resource/script lookup methods and updates provider/tool behavior to always expose the skill interaction tools.

Changes:

  • Replaces Skill.content with async get_content(), and adds async get_resource() / get_script() lookup methods.
  • Updates SkillsProvider to call async skill lookups and always register load_skill, read_skill_resource, and run_skill_script.
  • Revises skill tests for async content loading, always-present tools/instructions, and updated internal resource/script storage.

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 Refactors skill content/resource/script APIs and provider tool/instruction creation.
python/packages/core/tests/core/test_skills.py Updates unit tests to match async skill APIs and always-registered tool behavior.

@moonbox3
Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _skills.py8653196%289, 536, 548, 1002, 1017, 1019–1020, 1376–1377, 1389–1390, 1620, 1649, 2112, 2571–2572, 2707, 2712, 2715, 2720, 2747, 2752, 2806, 2815, 2820, 2823, 2828, 2852, 2857, 3099–3100
TOTAL36943433488% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
7379 34 💤 0 ❌ 0 🔥 1m 57s ⏱️

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Automated Code Review

Reviewers: 4 | Confidence: 84% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Design Approach


Automated review by semenshi's agents

@semenshi semenshi marked this pull request as ready for review May 28, 2026 10:11
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Automated Code Review

Reviewers: 4 | Confidence: 85%

✓ Correctness

No actionable issues found in this dimension.

✓ Security Reliability

No actionable issues found in this dimension.

✓ Test Coverage

No actionable issues found in this dimension.

✓ Design Approach

The async lookup refactor is mostly coherent, but the new InlineSkill/FileSkill lookup methods hard-code the private backing lists instead of going through an overridable collection hook. That makes these two skill types behave differently from ClassSkill and silently drops any subclass that customizes resource/script exposure via a property or descriptor. That change makes the tests validate private storage rather than the supported extension point, so they can miss regressions in implementations that customize scripts while still passing these tests.


Automated review by semenshi's agents

Comment thread python/packages/core/agent_framework/_skills.py
Comment thread python/packages/core/agent_framework/_skills.py
@semenshi semenshi enabled auto-merge May 28, 2026 12:02
@semenshi semenshi added this pull request to the merge queue May 28, 2026
Merged via the queue into microsoft:main with commit f7c5b8d May 28, 2026
41 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in Agent Framework May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Python: Add async on-demand skill content, resource, and script lookup

5 participants