Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Each run has its own `HOME` and `OH_PERSISTENCE_DIR`, so user skills, the instal
--check longdesc_full_in_prompt eq false --check longdesc_points_to_invoke_skill eq true \
--check longdesc_leaks_location eq false
```
Expected: the description is cut at 1024 characters with `Call invoke_skill(name="longdesc") to load the full skill`, and no file location is shown (`to_prompt` omits `<location>` on purpose). Known failure (reproduced 2026-10-13, not yet filed): `Skill` truncates the description when the `SKILL.md` is loaded, with the notice `<response clipped><NOTE>... You can view the complete skill content at /abs/path/.agents/skills/longdesc/SKILL.md.</NOTE>`, so the prompt carries the absolute file path and no `invoke_skill` pointer (`longdesc_points_to_invoke_skill` false, `longdesc_leaks_location` true). The unit test `test_to_prompt_truncates_long_descriptions` sets the description after construction and so never sees the load-time notice.
Expected: the description is cut at 1024 characters with `Call invoke_skill(name="longdesc") to load the full skill`, and no file location is shown (`to_prompt` omits `<location>` on purpose). `Skill` truncates a long description already when the `SKILL.md` is loaded; since #6644 that notice also points at `invoke_skill` and not at the file.
- **Path rules (`S07.path-rules`).** A `paths: [src/**/*.py]` AgentSkills rule and a nested `docs/AGENTS.md`; the scripted agent views `README.md`, `src/app/main.py`, `src/app/other.py` and `docs/guide.md` with `file_editor`.
```sh
export SDK_VERIFY_RUN=$(control-sdk new --field run)
Expand Down
18 changes: 9 additions & 9 deletions openhands-sdk/openhands/sdk/skills/skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
update_skills_repository,
validate_skill_name,
)
from openhands.sdk.utils import DEFAULT_TRUNCATE_NOTICE, maybe_truncate
from openhands.sdk.utils import maybe_truncate
from openhands.sdk.utils.path import get_user_persistence_dir, to_posix_path


Expand Down Expand Up @@ -245,7 +245,7 @@ class Skill(BaseModel):
description=(
"A brief description of what the skill does and when to use it. "
"Descriptions exceeding MAX_DESCRIPTION_LENGTH are truncated "
"with a notice pointing to the skill's source path."
"with a notice pointing to invoke_skill for the full skill."
),
)
license: str | None = Field(
Expand Down Expand Up @@ -291,10 +291,12 @@ class Skill(BaseModel):
),
)

# Points at invoke_skill, never at the file: to_prompt() leaves out the
# skill's location on purpose so the agent loads it through the tool.
_DESCRIPTION_TRUNCATE_NOTICE = (
"<response clipped><NOTE>Due to the max output limit, only part of "
"the full description is shown. You can view the complete skill "
"content at {source}.</NOTE>"
'the full description is shown. Call invoke_skill(name="{name}") to '
"load the full skill.</NOTE>"
)

@field_validator("allowed_tools", mode="before")
Expand Down Expand Up @@ -676,8 +678,8 @@ def _truncate_long_description(self):
"""Truncate description to MAX_DESCRIPTION_LENGTH via maybe_truncate.

Uses a model_validator (not field_validator) so the truncation notice
can reference self.source, telling the agent where to find the full
skill content.
can name the skill, pointing the agent to ``invoke_skill`` for the full
content. It never names the file (#6644).
"""
if (
self.description is not None
Expand All @@ -689,9 +691,7 @@ def _truncate_long_description(self):
len(self.description),
self.MAX_DESCRIPTION_LENGTH,
)
notice = DEFAULT_TRUNCATE_NOTICE
if self.source:
notice = self._DESCRIPTION_TRUNCATE_NOTICE.format(source=self.source)
notice = self._DESCRIPTION_TRUNCATE_NOTICE.format(name=self.name)
self.description = maybe_truncate(
self.description,
truncate_after=self.MAX_DESCRIPTION_LENGTH,
Expand Down
14 changes: 8 additions & 6 deletions tests/sdk/skills/test_validation_improvements.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Tests for skill validation improvements."""

from openhands.sdk.skills import Skill
from openhands.sdk.utils import DEFAULT_TRUNCATE_NOTICE


MAX_DESCRIPTION_LENGTH = 1024
Expand All @@ -21,15 +20,18 @@ def test_description_exceeds_limit_is_truncated() -> None:
skill = Skill(name="test", content="# Test", description=desc)
assert skill.description is not None
assert len(skill.description) == MAX_DESCRIPTION_LENGTH
# Without source, falls back to the default truncation notice
assert DEFAULT_TRUNCATE_NOTICE in skill.description
assert 'Call invoke_skill(name="test") to load the full skill.' in (
skill.description
)


def test_description_truncation_includes_source_path() -> None:
"""When source is set, truncation notice should reference the skill path."""
def test_description_truncation_points_at_invoke_skill_not_source() -> None:
"""The truncation notice names the skill for invoke_skill and never the
file: to_prompt() leaves the location out on purpose (#6644)."""
desc = "x" * (MAX_DESCRIPTION_LENGTH + 500)
source = "/path/to/my-skill/SKILL.md"
skill = Skill(name="test", content="# Test", description=desc, source=source)
assert skill.description is not None
assert len(skill.description) == MAX_DESCRIPTION_LENGTH
assert source in skill.description
assert source not in skill.description
assert 'invoke_skill(name="test")' in skill.description
20 changes: 20 additions & 0 deletions tests/sdk/skills/test_validation_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,23 @@ def test_to_prompt_truncation_points_at_invoke_skill_not_source() -> None:
assert "... [10 characters truncated" in result
assert 'invoke_skill(name="test")' in result
assert "/path/to/skill.md" not in result


def test_loaded_long_description_points_at_invoke_skill_not_path(tmp_path) -> None:
"""A long description truncated when SKILL.md is loaded must not leak the
file's path into the prompt; it points at invoke_skill instead (#6644)."""
skill_dir = tmp_path / ".agents" / "skills" / "longdesc"
skill_dir.mkdir(parents=True)
skill_md = skill_dir / "SKILL.md"
skill_md.write_text(
f"---\nname: longdesc\ndescription: {'C' * 2000}\n---\n# Long\nBody."
)

skill = Skill.load(skill_md)
result = to_prompt([skill])

assert skill.description is not None
assert len(skill.description) <= Skill.MAX_DESCRIPTION_LENGTH
assert 'invoke_skill(name="longdesc")' in result
assert str(skill_dir) not in result
assert "SKILL.md" not in result
Loading