diff --git a/agent/skill_commands.py b/agent/skill_commands.py index c8b7d039c46f..42e7c857434f 100644 --- a/agent/skill_commands.py +++ b/agent/skill_commands.py @@ -425,7 +425,7 @@ def build_skill_invocation_message( loaded = _load_skill_payload(skill_info["skill_dir"], task_id=task_id) if not loaded: - return f"[Failed to load skill: {skill_info['name']}]" + return None loaded_skill, skill_dir, skill_name = loaded diff --git a/tests/agent/test_skill_commands.py b/tests/agent/test_skill_commands.py index bbecd5c43f61..c11976ef9786 100644 --- a/tests/agent/test_skill_commands.py +++ b/tests/agent/test_skill_commands.py @@ -466,6 +466,14 @@ def test_returns_none_for_unknown(self, tmp_path): msg = build_skill_invocation_message("/nonexistent") assert msg is None + def test_returns_none_when_skill_load_fails(self, tmp_path): + with patch("tools.skills_tool.SKILLS_DIR", tmp_path): + _make_skill(tmp_path, "broken-skill") + scan_skill_commands() + with patch("agent.skill_commands._load_skill_payload", return_value=None): + msg = build_skill_invocation_message("/broken-skill", "do stuff") + assert msg is None + def test_uses_shared_skill_loader_for_secure_setup(self, tmp_path, monkeypatch): monkeypatch.delenv("TENOR_API_KEY", raising=False) calls = []