Agent Framework Integration (agentskills-agentframework)¶
Integrates skills into Microsoft Agent Framework.
pip install agentskills-agentframework
agentskills_agentframework ¶
Microsoft Agent Framework integration for Agent Skills.
This package bridges :mod:agentskills_core and Microsoft Agent Framework
<https://github.com/microsoft/agent-framework>_, providing:
- :class:
AgentSkillsContextProvider-- a :class:agent_framework.ContextProviderthat automatically injects skill awareness into an agent's session context. - :func:
get_tools-- generates eight :class:~agent_framework.FunctionToolinstances that let an AI agent consume skills. - :func:
get_tools_usage_instructions-- returns agent-facing instructions explaining how to use the tools. - :data:
METADATA_LOADED_SKILLS-- thecontext.metadatakey under which the provider publishes the skills loaded so far this session, for other context providers to read.
Install::
pip install agentskills-agentframework
AgentSkillsContextProvider ¶
Bases: ContextProvider
Expose a :class:~agentskills_core.SkillRegistry to an Agent Framework agent.
Wraps a registry of any-backend skills and hooks into the agent lifecycle to supply three things at the start of every run:
- Skills catalog — a compact listing of registered skill names and descriptions, appended to the session prompt.
- Typed tool set — eight
FunctionToolinstances that let the agent fetch metadata, full instructions, outlines, sections, references, scripts, and assets individually. - Tools usage instructions — guidance on the progressive-disclosure workflow so the agent knows how and when to invoke each tool.
Across a multi-turn session it also:
- Caches the assembled prompt in
state, keyed by the registry's skill set and the skills already loaded, so an unchanged session does no registry I/O after the first turn. - Records in
state["loaded_skills"]every skill whose full body the agent fetched, and prunes those entries from the catalog on later turns — their instructions are already in the conversation, so advertising them again is paid for twice. - Publishes the loaded set on
context.metadataunder"agentskills_loaded_skills"so other context providers can see what has been put in front of the model.
The tool surface intentionally uses typed resource tools
(get_skill_reference, get_skill_script, get_skill_asset)
rather than a single generic reader so that the agent has clear
semantic signal about the kind of content it is requesting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
registry
|
SkillRegistry
|
The :class: |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
skills_instruction_prompt |
str | None
|
Custom prompt template. Must contain
|
skills_catalog_format |
Literal['xml', 'markdown']
|
Format for the skills catalog —
|
cache_prompt |
bool
|
Reuse the assembled prompt across runs within a
session instead of rebuilding it from the registry every
turn. Pass |
prune_loaded_skills |
bool
|
Drop the catalog entry of any skill whose
full body the agent has already fetched this session,
replacing it with a one-line reminder. Pass |
fast_path |
FastPath | None
|
A :class: |
source_id |
str | None
|
Unique identifier for this provider instance. |
Example::
from agentskills_agentframework import AgentSkillsContextProvider
from agentskills_core import SkillRegistry
registry = SkillRegistry()
await registry.register("incident-response", provider)
skills_context_provider = AgentSkillsContextProvider(registry)
agent = client.as_agent(
name="SREAssistant",
instructions="You are an SRE assistant.",
context_providers=[skills_context_provider],
)
response = await agent.run("What severity is a full DB outage?")
after_run
async
¶
after_run(*, agent: SupportsAgentRun, session: AgentSession, context: SessionContext, state: dict[str, Any]) -> None
Record which skill bodies the agent pulled during this run.
Reads the agent's own response rather than wrapping the tools,
so a caller who passed :func:~agentskills_agentframework.get_tools
output in directly is tracked the same way.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
SupportsAgentRun
|
The agent that ran this invocation. |
required |
session
|
AgentSession
|
The active session. |
required |
context
|
SessionContext
|
The run context, with |
required |
state
|
dict[str, Any]
|
Provider-scoped mutable state persisted across runs. |
required |
before_run
async
¶
before_run(*, agent: SupportsAgentRun, session: AgentSession, context: SessionContext, state: dict[str, Any]) -> None
Append skills catalog, tools, and usage instructions to the run context.
Does nothing when the registry is empty, so agents without any registered skills pay no prompt-budget cost.
Calling this twice with the same context is a no-op the
second time: the context is marked once contributed to, so a
pipeline that retries a run cannot double the prompt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
SupportsAgentRun
|
The agent starting this run. |
required |
session
|
AgentSession
|
The active session. |
required |
context
|
SessionContext
|
Mutable run context to extend. |
required |
state
|
dict[str, Any]
|
Provider-scoped mutable state persisted across runs. |
required |
get_tools ¶
get_tools(registry: SkillRegistry, *, max_inline_binary_bytes: int = DEFAULT_MAX_INLINE_BINARY_BYTES, fast_path: FastPath | None = None, vision: bool = False, max_inline_image_bytes: int = DEFAULT_MAX_INLINE_IMAGE_BYTES) -> list[FunctionTool]
Build Agent Framework tools that expose an Agent Skills registry.
Each tool wraps a :class:~agentskills_core.SkillRegistry or
:class:~agentskills_core.Skill method, serialising the result
as JSON (for dicts) or plain text (for content bodies).
Tools are read-only -- they retrieve content but never execute
scripts or modify state.
Skill discovery is handled via the catalog in the system prompt,
so no list_skills tool is included.
All tools are async coroutines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
registry
|
SkillRegistry
|
The :class: |
required |
max_inline_binary_bytes
|
int
|
Size ceiling for inlining binary
resources as base64. Larger resources are described but
not returned. See
:func: |
DEFAULT_MAX_INLINE_BINARY_BYTES
|
fast_path
|
FastPath | None
|
A :class: |
None
|
vision
|
bool
|
When |
False
|
max_inline_image_bytes
|
int
|
Size ceiling for native images. Only
consulted when |
DEFAULT_MAX_INLINE_IMAGE_BYTES
|
Returns:
| Type | Description |
|---|---|
list[FunctionTool]
|
A list of :class: |
list[FunctionTool]
|
instances ready to be passed to an Agent Framework agent. |
get_tools_usage_instructions ¶
get_tools_usage_instructions() -> str
Return agent instructions for using the Agent Skills tools.
This text explains to an AI agent how to use the skill
tools (get_skill_metadata, get_skill_body,
get_skill_reference, get_skill_script, get_skill_asset)
following the progressive-disclosure workflow.
Combine with the skill catalog produced by
:meth:SkillRegistry.get_skills_catalog to give the agent both
what skills are available and how to interact with them::
catalog = await registry.get_skills_catalog(format="xml")
instructions = get_tools_usage_instructions()
system_prompt = f"{catalog}\n\n{instructions}"
Returns:
| Type | Description |
|---|---|
str
|
A multi-line instruction string ready for system-prompt |
str
|
insertion. |