mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-17 04:31:55 +00:00
fix(agent): add debug diagnostics for empty model responses
This commit is contained in:
parent
00c3d848d8
commit
38dab6dff4
9 changed files with 53 additions and 13 deletions
|
|
@ -969,6 +969,7 @@ class TestAgentCacheIdleResume:
|
|||
session_id="hard-session",
|
||||
)
|
||||
|
||||
import run_agent as _ra
|
||||
vm_calls: list = []
|
||||
# AIAgent.close() calls the ``cleanup_vm`` name bound into
|
||||
# ``run_agent`` at import time, not ``tools.terminal_tool.cleanup_vm``
|
||||
|
|
|
|||
|
|
@ -266,33 +266,33 @@ class TestFindAllSkillsFiltering:
|
|||
skills = _find_all_skills()
|
||||
assert not any(s["name"] == "my-skill" for s in skills)
|
||||
|
||||
@patch("agent.skill_utils.iter_skill_index_files")
|
||||
@patch("tools.skills_tool._get_disabled_skill_names", return_value=set())
|
||||
@patch("tools.skills_tool.skill_matches_platform", return_value=True)
|
||||
def test_enabled_skill_included(self, mock_platform, mock_disabled, tmp_path, monkeypatch):
|
||||
@patch("tools.skills_tool.SKILLS_DIR")
|
||||
def test_enabled_skill_included(self, mock_dir, mock_platform, mock_disabled, mock_iter, tmp_path):
|
||||
skill_dir = tmp_path / "my-skill"
|
||||
skill_dir.mkdir()
|
||||
skill_md = skill_dir / "SKILL.md"
|
||||
skill_md.write_text("---\nname: my-skill\ndescription: A test skill\n---\nContent")
|
||||
import tools.skills_tool as _st
|
||||
import agent.skill_utils as _su
|
||||
monkeypatch.setattr(_st, "SKILLS_DIR", tmp_path)
|
||||
monkeypatch.setattr(_su, "get_external_skills_dirs", lambda: [])
|
||||
mock_dir.exists.return_value = True
|
||||
mock_iter.return_value = [skill_md]
|
||||
from tools.skills_tool import _find_all_skills
|
||||
skills = _find_all_skills()
|
||||
assert any(s["name"] == "my-skill" for s in skills)
|
||||
|
||||
@patch("agent.skill_utils.iter_skill_index_files")
|
||||
@patch("tools.skills_tool._get_disabled_skill_names", return_value={"my-skill"})
|
||||
@patch("tools.skills_tool.skill_matches_platform", return_value=True)
|
||||
def test_skip_disabled_returns_all(self, mock_platform, mock_disabled, tmp_path, monkeypatch):
|
||||
@patch("tools.skills_tool.SKILLS_DIR")
|
||||
def test_skip_disabled_returns_all(self, mock_dir, mock_platform, mock_disabled, mock_iter, tmp_path):
|
||||
"""skip_disabled=True ignores the disabled set (for config UI)."""
|
||||
skill_dir = tmp_path / "my-skill"
|
||||
skill_dir.mkdir()
|
||||
skill_md = skill_dir / "SKILL.md"
|
||||
skill_md.write_text("---\nname: my-skill\ndescription: A test skill\n---\nContent")
|
||||
import tools.skills_tool as _st
|
||||
import agent.skill_utils as _su
|
||||
monkeypatch.setattr(_st, "SKILLS_DIR", tmp_path)
|
||||
monkeypatch.setattr(_su, "get_external_skills_dirs", lambda: [])
|
||||
mock_dir.exists.return_value = True
|
||||
mock_iter.return_value = [skill_md]
|
||||
from tools.skills_tool import _find_all_skills
|
||||
skills = _find_all_skills(skip_disabled=True)
|
||||
assert any(s["name"] == "my-skill" for s in skills)
|
||||
|
|
|
|||
|
|
@ -217,8 +217,14 @@ class FileToolsIntegrationTests(unittest.TestCase):
|
|||
def setUp(self) -> None:
|
||||
file_state.get_registry().clear()
|
||||
self._tmpdir = tempfile.mkdtemp(prefix="hermes_file_state_int_")
|
||||
self._orig_terminal_env = os.environ.get("TERMINAL_ENV")
|
||||
os.environ["TERMINAL_ENV"] = "local"
|
||||
|
||||
def tearDown(self) -> None:
|
||||
if self._orig_terminal_env is None:
|
||||
os.environ.pop("TERMINAL_ENV", None)
|
||||
else:
|
||||
os.environ["TERMINAL_ENV"] = self._orig_terminal_env
|
||||
import shutil
|
||||
shutil.rmtree(self._tmpdir, ignore_errors=True)
|
||||
file_state.get_registry().clear()
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import os
|
|||
import sys
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
from unittest.mock import patch
|
||||
|
||||
# Ensure repo root is importable
|
||||
_repo_root = Path(__file__).resolve().parent.parent.parent
|
||||
|
|
@ -33,6 +34,7 @@ except ImportError:
|
|||
class TestToolResolution:
|
||||
"""Verify get_tool_definitions returns all expected tools for eval."""
|
||||
|
||||
@patch.dict("os.environ", {"TERMINAL_ENV": "local"})
|
||||
def test_terminal_and_file_toolsets_resolve_all_tools(self):
|
||||
"""enabled_toolsets=['terminal', 'file'] should produce 6 tools."""
|
||||
from model_tools import get_tool_definitions
|
||||
|
|
@ -44,6 +46,7 @@ class TestToolResolution:
|
|||
expected = {"terminal", "process", "read_file", "write_file", "search_files", "patch"}
|
||||
assert expected == names, f"Expected {expected}, got {names}"
|
||||
|
||||
@patch.dict("os.environ", {"TERMINAL_ENV": "local"})
|
||||
def test_terminal_tool_present(self):
|
||||
"""The terminal tool must be present (not silently dropped)."""
|
||||
from model_tools import get_tool_definitions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue