feat: Add skills example and include skill location in agent prompt#1599
feat: Add skills example and include skill location in agent prompt#1599
Conversation
6d8c9bf to
7bcabfc
Compare
3ceb98c to
196692a
Compare
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>
bf54002 to
1c13815
Compare
|
@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. |
|
I'm on it! neubig can track my progress at all-hands.dev |
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>
|
I've created a PR on the OpenHands/docs repository documenting the skills example from PR #1599 on software-agent-sdk. PR CreatedChanges Made1. New Guide:
|
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>
|
Looks like there are a few issues preventing this PR from being merged!
If you'd like me to help, just leave a comment, like Feel free to include any additional details that might help me get this PR into a better state. You can manage your notification settings |
juanmichelini
left a comment
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
@graham could it be that instead of my-custom-skill it should berot13-encryption ?
|
@OpenHands fix this, I think my-custom-skill should be rot13-encryption |
|
I'm on it! neubig can track my progress at all-hands.dev |
…ption Co-authored-by: openhands <openhands@all-hands.dev>
|
I've fixed the issue and pushed the changes to the PR branch. SummaryIssue: The example code in Fix: Updated two lines in
Checklist
The PR #1599 has been updated with commit |
* 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>
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:
The example includes a ROT13 encryption skill that:
scripts/encrypt.shscript for ROT13 encodingreferences/examples.mdwith usage examples2. 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:
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 scriptexamples/05_skills_and_plugins/01_loading_agentskills/example_skills/rot13-encryption/SKILL.md- Skill definitionexamples/05_skills_and_plugins/01_loading_agentskills/example_skills/rot13-encryption/scripts/encrypt.sh- ROT13 scriptexamples/05_skills_and_plugins/01_loading_agentskills/example_skills/rot13-encryption/references/examples.md- Usage examplesopenhands-sdk/openhands/sdk/context/agent_context.py- Pass skill location to promptopenhands-sdk/openhands/sdk/context/prompts/templates/skill_knowledge_info.j2- Display skill locationopenhands-sdk/openhands/sdk/context/skills/types.py- Add location field to SkillKnowledgetests/sdk/context/test_agent_context.py- Update tests for new prompt formatTesting
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
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.12-nodejs22golang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:e6e71f4-pythonRun
All tags pushed for this build
About Multi-Architecture Support
e6e71f4-python) is a multi-arch manifest supporting both amd64 and arm64e6e71f4-python-amd64) are also available if needed