Skip to content

Conversation

@whywaita
Copy link
Contributor

@whywaita whywaita commented Oct 29, 2025

Summary

This PR implements automatic loading of user skills from the user's home directory, allowing users to define custom skills that are automatically available across all agents without explicit configuration.

Changes

Core Implementation

  • ✅ Added load_user_skills() function that loads skills from:
    • ~/.openhands/skills/ (primary location)
    • ~/.openhands/microagents/ (legacy support for backward compatibility)
  • ✅ Added load_user_skills field to AgentContext (default: True)
  • ✅ Implemented automatic merging of user skills with explicitly provided skills
  • ✅ Explicit skills take precedence over user skills when names conflict
  • ✅ Skills from ~/.openhands/skills/ take precedence over ~/.openhands/microagents/

API Updates

  • ✅ Exported load_user_skills function from openhands.sdk.context module
  • ✅ Added model validator to AgentContext for automatic user skills loading

Testing

  • ✅ Added comprehensive test suite (tests/sdk/context/skill/test_load_user_skills.py)
    • Tests for loading from both directories
    • Tests for priority and precedence rules
    • Tests for duplicate handling
    • Tests for error handling
    • Tests for AgentContext integration
  • ✅ Updated existing tests to disable user skills loading where appropriate

Behavior

When enabled (default)

  • User skills are automatically loaded from home directory
  • Merged with any explicitly provided skills
  • Duplicate names are handled gracefully (explicit skills take precedence)

When disabled (load_user_skills=False)

  • Only explicitly provided skills are used
  • No automatic loading occurs

Testing

  • All new tests pass
  • Existing tests updated and passing
  • Error handling tested (invalid skills, missing directories)
  • Priority and precedence rules verified

Related

fixes: OpenHands/OpenHands#11483

@blacksmith-sh blacksmith-sh bot requested a review from xingyaoww October 31, 2025 13:00
@blacksmith-sh
Copy link
Contributor

blacksmith-sh bot commented Oct 31, 2025

[Automatic Post]: I have assigned @xingyaoww as a reviewer based on git blame information. Thanks in advance for the help!

@xingyaoww
Copy link
Collaborator

@OpenHands make sure pre-commit run --all-files pass on this branch. You are on a fork branch "whywaita:feat/implement-user-skills", please update your remote URL before you push y our changes.

@openhands-ai
Copy link

openhands-ai bot commented Nov 4, 2025

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

@openhands-ai
Copy link

openhands-ai bot commented Nov 4, 2025

Summary

I've successfully made the pre-commit checks pass on the feat/implement-user-skills branch and pushed the changes to the fork.

What was done:

Checked out the branch: Successfully fetched and checked out whywaita:feat/implement-user-skills

Ran pre-commit checks: Identified formatting issues in tests/sdk/context/test_agent_context.py

Fixed formatting issues: The ruff formatter reformatted 3 lines in the test file to split long AgentContext constructor calls across multiple lines for better readability

Committed changes: Created commit with message "style: Format code with ruff" and proper co-author attribution

Verified all checks pass: All pre-commit hooks now pass successfully:

  • Format YAML files ✓
  • Ruff format ✓
  • Ruff lint ✓
  • PEP8 style check ✓
  • Type check with basedpyright ✓

Pushed to fork: Successfully pushed the changes to whywaita/agent-sdk repository

Changes made:

  • File modified: tests/sdk/context/test_agent_context.py (9 insertions, 3 deletions)
  • Change type: Code formatting only - split long lines to comply with style guidelines

The PR #950 has been updated with the formatting fix and all pre-commit checks now pass on the branch.

View full conversation

context = AgentContext(skills=[python_agent, testing_agent])
context = AgentContext(
load_user_skills=False, skills=[python_agent, testing_agent]
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

@OpenHands you are on a fork branch whywaita:feat/implement-user-skills (pls reset the remote url before you push) - load_user_skills should be optional arg, can you remove the changes we added in test_agent_context.py in this PR?

Copy link

Choose a reason for hiding this comment

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

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

Copy link

Choose a reason for hiding this comment

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

Summary of Changes

I've successfully completed your request to clean up the test files in PR #950. Here's what was done:

Changes Made (2 commits):

Commit 1: 9bdec4c8 - "Remove explicit load_user_skills=False from test_agent_context.py"

  • ✅ Removed all explicit load_user_skills=False parameters from test_agent_context.py
  • This eliminated ~16 redundant parameter assignments since False is already the default value

Commit 2: f402f638 - "Fix tests: explicitly set load_user_skills=True where needed"

  • ✅ Fixed 3 tests in test_load_user_skills.py that were failing after the default value change
  • These tests specifically verify the auto-loading functionality, so they need load_user_skills=True
  • Updated tests:
    • test_agent_context_loads_user_skills_by_default
    • test_agent_context_merges_explicit_and_user_skills
    • test_agent_context_explicit_skill_takes_precedence

Test Results:

  • ✅ All 111 tests in tests/sdk/context/ pass
  • ✅ Pre-commit hooks pass (Ruff format, Ruff lint, pycodestyle, pyright)

PR Status:

The PR is now cleaner with redundant parameters removed while maintaining full test coverage and functionality.

View full conversation

Since load_user_skills defaults to False in AgentContext, there's no need
to explicitly set it in tests. This makes the tests cleaner and relies on
the default behavior.

Co-authored-by: openhands <[email protected]>
Since load_user_skills defaults to False, tests that expect automatic
loading of user skills need to explicitly enable it.

Updated tests:
- test_agent_context_loads_user_skills_by_default
- test_agent_context_merges_explicit_and_user_skills
- test_agent_context_explicit_skill_takes_precedence

Co-authored-by: openhands <[email protected]>
Copy link
Collaborator

@xingyaoww xingyaoww left a comment

Choose a reason for hiding this comment

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

Thanks!

@xingyaoww xingyaoww merged commit b8de86c into OpenHands:main Nov 4, 2025
13 checks passed
@enyst
Copy link
Collaborator

enyst commented Nov 4, 2025

@OpenHands Post an issue on OpenHands/OpenHands, tag it as CLI, for the CLI to

  • offer a setting for users to enable loading Skills from user home (what this PR does)
  • enable it by default in CLI.

@openhands-ai
Copy link

openhands-ai bot commented Nov 4, 2025

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

@openhands-ai
Copy link

openhands-ai bot commented Nov 4, 2025

Summary of work completed

What’s in the issue

  • Clear proposal for:
    • A config option and CLI flags to enable/disable loading user Skills
    • Default behavior: enabled
    • Wiring CLI to pass load_user_skills=True to AgentContext
  • Acceptance criteria aligning with SDK behavior (explicit > user; skills/ > microagents/)
  • References:

Checks

  • Verified existing CLI label in OpenHands/OpenHands
  • No changes were made to the current repository or branch (feat/implement-user-skills)

If you want any edits to the issue’s title, scope, or acceptance criteria, I can update it.

View full conversation

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.

[Bug]: [CLI V1]: User microagents from ~/.openhands/microagents/ not loaded in openhands-cli

4 participants