Skip to content

LangChain Integration (agentskills-langchain)

Exposes skills as LangChain tools.

pip install agentskills-langchain

agentskills_langchain

LangChain integration for Agent Skills.

This package bridges :mod:agentskills_core and LangChain <https://python.langchain.com>_, providing:

  • :func:get_tools -- generates five :class:~langchain_core.tools.StructuredTool instances that let an LLM agent consume skills.
  • :func:get_tools_usage_instructions -- returns agent-facing instructions explaining how to use the tools.

Install::

pip install agentskills-langchain

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[StructuredTool]

Build LangChain 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:~agentskills_core.SkillRegistry whose skills should be exposed as tools.

required
max_inline_binary_bytes int

Size ceiling for inlining binary resources as base64. Larger resources are described but not returned. See :func:~agentskills_core.encode_resource_content.

DEFAULT_MAX_INLINE_BINARY_BYTES
fast_path FastPath | None

A :class:~agentskills_core.FastPath from :func:~agentskills_core.resolve_fast_path. When given, the four body-access tools are omitted, because the body is already in the prompt. Resource tools remain. Use fast_path.prompt in place of the catalog and :func:get_tools_usage_instructions.

None
vision bool

When True, bundled images small enough to inline are returned as native image content blocks instead of a base64 JSON envelope. Off by default: handing an image block to a text-only model is an API error, not a degraded answer, so the caller declares the capability rather than the library guessing it.

False
max_inline_image_bytes int

Size ceiling for native images. Only consulted when vision is True. Larger images fall back to the JSON envelope.

DEFAULT_MAX_INLINE_IMAGE_BYTES

Returns:

Type Description
list[StructuredTool]

A list of :class:~langchain_core.tools.StructuredTool

list[StructuredTool]

instances ready to be passed to a LangChain agent.

get_tools_usage_instructions

get_tools_usage_instructions() -> str

Return agent instructions for using the Agent Skills tools.

This text explains to an LLM 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.