Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/harness/openhands/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def _import_openhands_sdk() -> Any:


def _import_openhands_skills() -> Any:
return importlib.import_module("openhands.sdk.context.skills")
try:
return importlib.import_module("openhands.sdk.skills")
except ImportError:
return importlib.import_module("openhands.sdk.context.skills")


def _import_openhands_llm() -> Any:
Expand Down
45 changes: 44 additions & 1 deletion tests/test_openhands_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def _install_fake_openhands(
final_message: str,
extracted_message: str | None = None,
metrics: dict | None = None,
skills_module_path: str = "openhands.sdk.context.skills",
) -> dict[str, object]:
captured: dict[str, object] = {}

Expand Down Expand Up @@ -128,7 +129,7 @@ def __init__(self, *, role: str, content):
monkeypatch.setitem(sys.modules, "openhands.sdk", sdk_module)
monkeypatch.setitem(
sys.modules,
"openhands.sdk.context.skills",
skills_module_path,
SimpleNamespace(load_skills_from_dir=fake_load_skills_from_dir),
)
monkeypatch.setitem(
Expand Down Expand Up @@ -204,6 +205,48 @@ def test_openhands_runtime_uses_direct_json_without_fallback(
assert captured["register_default_tools"] == {"enable_browser": False}


def test_openhands_runtime_loads_skills_from_current_sdk_module(
monkeypatch: pytest.MonkeyPatch,
tmp_path: Path,
) -> None:
set_sdk("openhands")
skills_dir = tmp_path / ".claude" / "skills" / "repo-skill"
skills_dir.mkdir(parents=True)
(skills_dir / "SKILL.md").write_text("---\nname: repo-skill\ndescription: Repo-local skill\n---\n")

monkeypatch.delitem(sys.modules, "openhands.sdk.context.skills", raising=False)
captured = _install_fake_openhands(
monkeypatch,
final_message='{"final_answer":"4","reasoning":"basic arithmetic"}',
skills_module_path="openhands.sdk.skills",
)

agent = Agent(
{
"sdk": "openhands",
"system": "Answer the question with the final answer only.",
"format": {
"type": "json_schema",
"schema": AgentResponse.model_json_schema(),
},
"tools": ["Read", "Edit", "Bash", "TodoWrite", "Skill"],
"provider_id": "anthropic",
"model_id": "claude-sonnet-4-5-20250929",
"model": "anthropic/claude-sonnet-4-5-20250929",
"cwd": str(tmp_path),
"skills_dir": str(tmp_path / ".claude" / "skills"),
"add_dirs": [],
},
AgentResponse,
)

trace = asyncio.run(agent.run("What is 2 + 2?"))

assert trace.output is not None
assert trace.output.final_answer == "4"
assert captured["skills_dir"] == str(tmp_path / ".claude" / "skills")


def test_openhands_runtime_falls_back_to_strict_extraction_when_final_text_is_not_json(
monkeypatch: pytest.MonkeyPatch,
tmp_path: Path,
Expand Down