Skip to content

feat: Add skills example and include skill location in agent prompt#1599

Merged
neubig merged 3 commits intomainfrom
examples/skills-and-plugins
Jan 7, 2026
Merged

feat: Add skills example and include skill location in agent prompt#1599
neubig merged 3 commits intomainfrom
examples/skills-and-plugins

Conversation

@neubig
Copy link
Contributor

@neubig neubig commented Jan 6, 2026

Summary

This PR adds a comprehensive example demonstrating how to load and use AgentSkills with the software-agent-sdk, and fixes an issue where skill location was not being passed to the agent prompt.

Changes

1. New Example: examples/05_skills_and_plugins/01_loading_agentskills/

A concrete example showing how to:

  • Create a skill directory with SKILL.md, scripts/, and references/
  • Load skills from a custom directory
  • Use keyword triggers to activate skills
  • Access skill resources (scripts, references) from the agent

The example includes a ROT13 encryption skill that:

  • Triggers on keywords: "encrypt", "decrypt", "cipher"
  • Provides a scripts/encrypt.sh script for ROT13 encoding
  • Includes references/examples.md with usage examples

2. Skill Location in Agent Prompt

Fixed an issue where the skill location (directory path) was not being passed to the agent prompt. Now when a skill is triggered, the agent sees:

<EXTRA_INFO>
The following information has been included based on a keyword match for "encrypt".
It may or may not be relevant to the user's request.

Skill location: /path/to/rot13-encryption
(Use this path to resolve relative file references in the skill content below)

[skill content]
</EXTRA_INFO>

This allows the agent to correctly resolve relative paths to scripts and references mentioned in the skill content.

Files Changed

  • examples/05_skills_and_plugins/01_loading_agentskills/main.py - Example script
  • examples/05_skills_and_plugins/01_loading_agentskills/example_skills/rot13-encryption/SKILL.md - Skill definition
  • examples/05_skills_and_plugins/01_loading_agentskills/example_skills/rot13-encryption/scripts/encrypt.sh - ROT13 script
  • examples/05_skills_and_plugins/01_loading_agentskills/example_skills/rot13-encryption/references/examples.md - Usage examples
  • openhands-sdk/openhands/sdk/context/agent_context.py - Pass skill location to prompt
  • openhands-sdk/openhands/sdk/context/prompts/templates/skill_knowledge_info.j2 - Display skill location
  • openhands-sdk/openhands/sdk/context/skills/types.py - Add location field to SkillKnowledge
  • tests/sdk/context/test_agent_context.py - Update tests for new prompt format

Testing

Ran the example successfully - agent encrypted "hello world" → "uryyb jbeyq" using the ROT13 skill.

All existing tests pass with updated expected outputs.

Co-authored-by: openhands openhands@all-hands.dev


Agent Server images for this PR

GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python amd64, arm64 nikolaik/python-nodejs:python3.12-nodejs22 Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:e6e71f4-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-e6e71f4-python \
  ghcr.io/openhands/agent-server:e6e71f4-python

All tags pushed for this build

ghcr.io/openhands/agent-server:e6e71f4-golang-amd64
ghcr.io/openhands/agent-server:e6e71f4-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:e6e71f4-golang-arm64
ghcr.io/openhands/agent-server:e6e71f4-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:e6e71f4-java-amd64
ghcr.io/openhands/agent-server:e6e71f4-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:e6e71f4-java-arm64
ghcr.io/openhands/agent-server:e6e71f4-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:e6e71f4-python-amd64
ghcr.io/openhands/agent-server:e6e71f4-nikolaik_s_python-nodejs_tag_python3.12-nodejs22-amd64
ghcr.io/openhands/agent-server:e6e71f4-python-arm64
ghcr.io/openhands/agent-server:e6e71f4-nikolaik_s_python-nodejs_tag_python3.12-nodejs22-arm64
ghcr.io/openhands/agent-server:e6e71f4-golang
ghcr.io/openhands/agent-server:e6e71f4-java
ghcr.io/openhands/agent-server:e6e71f4-python

About Multi-Architecture Support

  • Each variant tag (e.g., e6e71f4-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., e6e71f4-python-amd64) are also available if needed

@neubig neubig force-pushed the examples/skills-and-plugins branch from 6d8c9bf to 7bcabfc Compare January 6, 2026 01:33
@neubig neubig force-pushed the examples/skills-and-plugins branch from 3ceb98c to 196692a Compare January 6, 2026 02:39
@neubig neubig marked this pull request as ready for review January 6, 2026 03:25
This PR adds:

1. **Skill location in agent prompt**: When a skill is triggered, the agent
   now receives the skill's file path so it can resolve relative references
   to scripts/, references/, and assets/ directories.

2. **Skills and plugins example**: A concrete example demonstrating:
   - Loading skills from disk following the AgentSkills standard
   - A ROT13 encryption skill with scripts/encrypt.sh
   - Agent using the skill to encrypt 'hello world' → 'uryyb jbeyq'

Changes:
- Add `location` field to SkillKnowledge type
- Pass skill source path to prompt template
- Add examples/05_skills_and_plugins/01_loading_agentskills/

Co-authored-by: openhands <openhands@all-hands.dev>
@neubig neubig force-pushed the examples/skills-and-plugins branch from bf54002 to 1c13815 Compare January 6, 2026 03:31
@neubig neubig changed the title Add examples/05_skills_and_plugins directory with skill loading examples feat: Add skills example and include skill location in agent prompt Jan 6, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-sdk/openhands/sdk/context
   agent_context.py1164660%87, 92, 102–103, 105–108, 110, 114–115, 117, 124–125, 127–130, 132, 136–138, 150–156, 184, 188, 204–206, 221, 229–231, 235, 238, 243, 252, 257–259, 264
TOTAL14875713852% 

@neubig
Copy link
Contributor Author

neubig commented Jan 6, 2026

@OpenHands based on this PR, also open a PR on the OpenHands/docs repo documenting this example. Follow the best practices there, including using the "sync" command to sync the code. Make sure that the way you implement it, the check-examples workflow will pass.

@openhands-ai
Copy link

openhands-ai bot commented Jan 6, 2026

I'm on it! neubig can track my progress at all-hands.dev

neubig pushed a commit to OpenHands/docs that referenced this pull request Jan 6, 2026
This adds documentation for the new example in software-agent-sdk that
demonstrates how to load skills following the AgentSkills standard from
a directory on disk.

The guide covers:
- AgentSkills directory structure (SKILL.md, scripts/, references/, assets/)
- Using load_skills_from_dir() and discover_skill_resources()
- How skill location is passed to the agent prompt
- A complete example with ROT13 encryption skill

Related to: OpenHands/software-agent-sdk#1599

Co-authored-by: openhands <openhands@all-hands.dev>
@openhands-ai
Copy link

openhands-ai bot commented Jan 6, 2026

I've created a PR on the OpenHands/docs repository documenting the skills example from PR #1599 on software-agent-sdk.

PR Created

OpenHands/docs#238

Changes Made

1. New Guide: sdk/guides/skill-loading.mdx

A comprehensive guide covering:

  • AgentSkills directory structure (SKILL.md, scripts/, references/, assets/)
  • SKILL.md format with YAML frontmatter
  • Using load_skills_from_dir() and discover_skill_resources() functions
  • How skill location is passed to the agent prompt for resolving relative paths
  • Complete ROT13 encryption example

2. Navigation Update: docs.json

Added the new guide to the SDK Guides section, placed after the existing "Agent Skills & Context" guide.

Sync Compatibility

The guide includes a code block that references examples/05_skills_and_plugins/01_loading_agentskills/main.py using the sync format:

```python icon="python" expandable examples/05_skills_and_plugins/01_loading_agentskills/main.py

This follows the pattern used by other guides, allowing the sync-docs-code-blocks workflow to automatically keep the documentation in sync with the source code.

Verification

View full conversation

neubig pushed a commit to OpenHands/docs that referenced this pull request Jan 6, 2026
This adds documentation for the new example in software-agent-sdk that
demonstrates how to use skills following the AgentSkills standard
(compatible with Claude's format).

The guide covers:
- AgentSkills directory structure (SKILL.md, scripts/, references/, assets/)
- Using load_skills_from_dir() and discover_skill_resources()
- How skill location is passed to the agent prompt
- A complete example with ROT13 encryption skill

Related to: OpenHands/software-agent-sdk#1599

Co-authored-by: openhands <openhands@all-hands.dev>
@neubig neubig requested a review from juanmichelini January 6, 2026 16:05
@openhands-ai
Copy link

openhands-ai bot commented Jan 7, 2026

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • [Optional] Docs example

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #1599 at branch `examples/skills-and-plugins`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

Copy link
Collaborator

@juanmichelini juanmichelini left a comment

Choose a reason for hiding this comment

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

assuming that "my-custom-skill" is intended instead of "rot13-encryption" LGTM !

print(f"Loading skills from: {example_skills_dir}")

# Discover resources in the skill directory
skill_subdir = example_skills_dir / "my-custom-skill"
Copy link
Collaborator

Choose a reason for hiding this comment

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

@graham could it be that instead of my-custom-skill it should berot13-encryption ?

@neubig
Copy link
Contributor Author

neubig commented Jan 7, 2026

@OpenHands fix this, I think my-custom-skill should be rot13-encryption

@openhands-ai
Copy link

openhands-ai bot commented Jan 7, 2026

I'm on it! neubig can track my progress at all-hands.dev

…ption

Co-authored-by: openhands <openhands@all-hands.dev>
@openhands-ai
Copy link

openhands-ai bot commented Jan 7, 2026

I've fixed the issue and pushed the changes to the PR branch.

Summary

Issue: The example code in examples/05_skills_and_plugins/01_loading_agentskills/main.py was referencing a non-existent skill directory my-custom-skill instead of the actual skill directory rot13-encryption.

Fix: Updated two lines in main.py:

  • Line 45: Changed skill_subdir = example_skills_dir / "my-custom-skill" to skill_subdir = example_skills_dir / "rot13-encryption"
  • Line 47: Changed the print statement from "my-custom-skill/" to "rot13-encryption/"

Checklist

  • ✅ Changed my-custom-skill to rot13-encryption as requested
  • ✅ Pre-commit hooks passed (ruff format, ruff lint, pycodestyle, pyright)
  • ✅ Changes are minimal and focused on the fix
  • ✅ Committed and pushed to the examples/skills-and-plugins branch

The PR #1599 has been updated with commit d101667c.

View full conversation

@neubig neubig merged commit 9aff9be into main Jan 7, 2026
21 of 22 checks passed
@neubig neubig deleted the examples/skills-and-plugins branch January 7, 2026 16:23
xingyaoww added a commit to OpenHands/docs that referenced this pull request Jan 8, 2026
* docs: Add guide for using skills in AgentSkills/Claude format

This adds documentation for the new example in software-agent-sdk that
demonstrates how to use skills following the AgentSkills standard
(compatible with Claude's format).

The guide covers:
- AgentSkills directory structure (SKILL.md, scripts/, references/, assets/)
- Using load_skills_from_dir() and discover_skill_resources()
- How skill location is passed to the agent prompt
- A complete example with ROT13 encryption skill

Related to: OpenHands/software-agent-sdk#1599

Co-authored-by: openhands <openhands@all-hands.dev>

* docs: Sync code blocks with agent-sdk source files

- Update skill-loading.mdx to use rot13-encryption skill directory name
- Update pr-review.mdx workflow file

Co-authored-by: openhands <openhands@all-hands.dev>

* docs: Merge skill-loading.mdx into skill.mdx

Per reviewer feedback, combined the AgentSkills/Claude format documentation
directly into the existing skill.mdx file and reorganized for better flow:

- Added 'Inline Skills' section for code-defined skills
- Added 'Loading Skills from Disk (AgentSkills Standard)' section with:
  - Directory structure
  - SKILL.md format
  - Loading functions (load_skills_from_dir, discover_skill_resources)
  - Skill location in prompts
  - ROT13 encryption example
- Renamed 'Message Suffixes' section to 'Customizing Agent Context'
- Removed separate skill-loading.mdx file
- Updated docs.json navigation to remove skill-loading entry

Co-authored-by: openhands <openhands@all-hands.dev>

* chore: sync pr-review.mdx code block with SDK repo

The SDK repository was renamed from agent-sdk to software-agent-sdk.
This commit syncs the workflow example to match the current SDK source.

Co-authored-by: openhands <openhands@all-hands.dev>

* Apply suggestions from code review

* docs: Document how triggered skills are auto-added to system prompt

- Add 'How Triggered Skills Work' section explaining automatic skill listing
- Show the <SKILLS> XML block format in system prompt
- Update 'Skill Location in Prompts' to reference the new section
- Explain that agents can proactively look up skill content

Co-authored-by: openhands <openhands@all-hands.dev>

* docs: Document how skills appear in the system prompt

- Add 'How Skills Appear in the System Prompt' section
- Explain difference between always-active and triggered skills
- Show the <SKILLS> XML block format for triggered skills
- Update 'Skill Location in Prompts' to reference the new section

Co-authored-by: openhands <openhands@all-hands.dev>

* docs: Clarify triggers field behavior for AgentSkills standard

Add note explaining that triggers field is optional - skills without
triggers are always active with full content in system prompt.

Co-authored-by: openhands <openhands@all-hands.dev>

* docs: Reorganize skill docs to clarify AgentSkills standard vs OpenHands extensions

- Add overview table comparing standard vs OpenHands features
- Clarify that 'triggers' field is an OpenHands extension
- Add warning about portability when using triggers
- Update SKILL.md format section with field source annotations
- Improve tables showing trigger behavior and system prompt handling
- Reference official AgentSkills specification (agentskills.io)

Co-authored-by: openhands <openhands@all-hands.dev>

* docs: Add note about known limitation with progressive disclosure

Link to issue #1646 discussing alignment with AgentSkills standard
for skills without triggers.

Co-authored-by: openhands <openhands@all-hands.dev>

* docs: Rewrite skill documentation with clear categorization rules

Major rewrite of skill documentation to clearly explain:
- AgentSkills progressive disclosure model
- Skill categorization flow diagram
- Behavior differences between AgentSkills and legacy formats
- How triggers work with AgentSkills format (best of both worlds)

Key clarifications:
- SKILL.md files always use progressive disclosure
- SKILL.md with triggers: listed in available_skills AND auto-inject on trigger
- Legacy skills without triggers: full content in REPO_CONTEXT
- Legacy skills with triggers: listed in available_skills, inject on trigger

Co-authored-by: openhands <openhands@all-hands.dev>

* docs: Improve skill documentation with cleaner visual presentation

- Replace ugly ASCII flow diagram with CardGroup cards
- Simplify behavior table to focus on user-facing behavior
- Use Tabs component for system prompt examples
- Remove internal implementation details (is_agentskills_format)
- Clarify that OpenHands extends AgentSkills standard with triggers
- Change Warning to Info for triggers extension (it's a feature, not a problem)

Co-authored-by: openhands <openhands@all-hands.dev>

* docs: Add AgentSkills standard reference to skills overview

Co-authored-by: openhands <openhands@all-hands.dev>

* docs: Reorganize skill documentation for clarity

Major reorganization focused on user understanding:

1. Start with 'Two Types of Skills' - the key concept users need
2. Add 'Quick Start' with minimal code example
3. Add 'How It Works' with Steps component showing the flow
4. Simplify SKILL.md section with cleaner frontmatter table
5. Remove confusing 'How Skills Appear in System Prompt' section
   (this was implementation detail, not user-facing)
6. Use Tip instead of Info for actionable advice

The goal is: users understand WHAT skills do before HOW to configure them.

Co-authored-by: openhands <openhands@all-hands.dev>

* docs: Clarify relationship between AGENTS.md and Skills

Reorganize documentation to clearly show the three approaches:

1. AGENTS.md (Recommended for repos)
   - At repo root, auto-loaded
   - Model variants: CLAUDE.md, GEMINI.md
   - Works with other AI tools

2. Keyword-Triggered Skills
   - Activated by keywords in user messages
   - Content injected as <EXTRA_INFO>
   - Keeps system prompt lean

3. Always-Active Skills (Code-Based)
   - For programmatic control
   - Full content in system prompt

This makes it clear when to use each approach.

Co-authored-by: openhands <openhands@all-hands.dev>

* docs: Restructure SDK skill guide around loading methods

Reorganize to focus on SDK implementation with clear loading methods:

1. Always-loaded context
   - AGENTS.md (auto-loaded via load_project_skills)
   - Inline skills (trigger=None)

2. Trigger-loaded context
   - KeywordTrigger for on-demand injection

3. Progressive disclosure (AgentSkills)
   - SKILL.md format via load_skills_from_dir
   - Optional triggers for both listing AND injection

Reference overview pages for concepts, focus on code here.

Co-authored-by: openhands <openhands@all-hands.dev>

* Update sdk/guides/skill.mdx

Co-authored-by: Engel Nyst <engel.nyst@gmail.com>

* Update sdk/guides/skill.mdx

Co-authored-by: Engel Nyst <engel.nyst@gmail.com>

---------

Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: Xingyao Wang <xingyao@all-hands.dev>
Co-authored-by: Engel Nyst <engel.nyst@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants