Skip to main content

Langchain adapters to support skills in your agent

Project description

Langchain Skills Adapters

CI coverage

Langchain adapters to support skills in your agent.

Features

Installation

uv:

uv add langchain-skills-adapters

pip:

pip install langchain-skills-adapters

Skills Format

The skill directory must be in the following format to be loaded correctly:

skills/
├── skill-name/
│   ├── SKILL.md        # Required: instructions + metadata
│   ├── scripts/        # Optional: executable code
│   ├── references/     # Optional: documentation
│   ├── assets/         # Optional: templates, resources
│   └── ...             # Any other additional files or directories        
└── other skills...

Skills must follow the Anthropic Open Standard for Skills. This includes having frontmatter with at minimum the name and skill description.

---
name: My Skill
description: This is my skill
---

# My Skill

Skill content

Usage

As Middleware

The SkillsMiddleware is a Langchain middleware that adds skill info to your agent's system prompt before each model call. It also adds a skills_file_read tool to your agent's tool list, allowing it to read skill files and other resources from your skills directory. This way, your agent will always see what skills are available to it before acting, and can use the tool to read skill files and other resource files.

from langchain.agents import create_agent

from langchain_skills_adapters import SkillsMiddleware

# Create the SkillsMiddleware pointed to your skills directory
skills_dir = "/path/to/skills/"
skills_middleware = SkillsMiddleware(skills_dir)

# Create the agent
agent = create_agent("openai:gpt-5", middleware=[skills_middleware])
response = agent.invoke(input={"messages": {"role": "user", "content": "What skills do you have?"}})

The SkillsMiddleware also supports dynamic tool registration, adding new tools to your agent as skills get activated. When a skill is activated by your agent, all the tools listed in the allowed-tools field of that skill is added to the agent's tool list. This allows you to add new tools to your agent on the fly, preventing the agent's context from being overfilled with tools.

For example, if you have a skill with allowed-tools: say_hello, you can add that tool to be dynamically registered when the skill is activated like so:

from langchain.agents import create_agent
from langchain_core.tools import tool

from langchain_skills_adapters import SkillsMiddleware

@tool
def say_hello(name: str):
    return "Hello, " + name

# Create the dynamic tools dictionary
# This should map the name of the tool in allowed-tools to a single tool or a list of tools
tools = [say_hello]
dynamic_tools = {tool.name: tool for tool in tools}

# Create the SkillsMiddleware with dynamic tools
skills_dir = "/path/to/skills/"
skills_middleware = SkillsMiddleware(skills_dir, dynamic_tools=dynamic_tools)

# Create the agent
agent = create_agent("openai:gpt-5", middleware=[skills_middleware])
response = agent.invoke(input={"messages": {"role": "user", "content": "What skills do you have?"}})

As a Tool

The SkillsTool creates a Langchain tool that can be used by your agent to activate a skill. The description of the skills tool contains names and descriptions of all available skills from your skill directory. This way, your agent will always see what skills are available to it before acting, and can use the tool to activate a skill and read its full content.

If your skills directory contains resource files (such as scripts, assets, etc.), you can add a ReadFileTool to enable your agent to read these files.

from langchain.agents import create_agent
from langchain_community.tools.file_management.read import ReadFileTool

from langchain_skills_adapters import SkillsTool

# Create the SkillsTool pointed to your skills directory
skills_dir = "/path/to/skills/"
skills_tool = SkillsTool(skills_dir)

# Optional: Add a file reading tool. Recommended if your agent needs to read resources from your skills directory (scripts, assets, etc.)
read_file_tool = ReadFileTool(root_dir=skills_dir)

# Create the agent
tools = [skills_tool, read_file_tool]
agent = create_agent("openai:gpt-5", tools=tools)
response = agent.invoke(input={"messages": {"role": "user", "content": "What skills do you have?"}})

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_skills_adapters-0.1.6rc3.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_skills_adapters-0.1.6rc3-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file langchain_skills_adapters-0.1.6rc3.tar.gz.

File metadata

File hashes

Hashes for langchain_skills_adapters-0.1.6rc3.tar.gz
Algorithm Hash digest
SHA256 5489597e0d4586a59833c5edd12bf1542c371dc9b96a7756506c80b8d4d19109
MD5 4289dc1d3a12f108c07fc7528b2e8e99
BLAKE2b-256 39a4e08a1f0fed315f2079cd7cb8374afe2ca189288fcec4e12d8294815b66ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_skills_adapters-0.1.6rc3.tar.gz:

Publisher: release.yml on taagarwa-rh/langchain-skills-adapters

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_skills_adapters-0.1.6rc3-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_skills_adapters-0.1.6rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 4820821e5e2ed25966afbfc442f7920c02329e40add4a0b180432b87617b5c63
MD5 af656fec787a9e74adac3e6405a3f53c
BLAKE2b-256 a56e40ea63cf45beeff75187d9779875996846de522f98b5d4229a26b26c94e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_skills_adapters-0.1.6rc3-py3-none-any.whl:

Publisher: release.yml on taagarwa-rh/langchain-skills-adapters

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page