mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 01:21:43 +00:00
fix(kimi): cover remaining fixed-temperature bypasses
This commit is contained in:
parent
53e4a2f2c6
commit
148459716c
7 changed files with 145 additions and 20 deletions
|
|
@ -2,11 +2,13 @@
|
|||
|
||||
import ast
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import patch as mock_patch
|
||||
|
||||
import tools.approval as approval_module
|
||||
from tools.approval import (
|
||||
_get_approval_mode,
|
||||
_smart_approve,
|
||||
approve_session,
|
||||
detect_dangerous_command,
|
||||
is_approved,
|
||||
|
|
@ -26,6 +28,21 @@ class TestApprovalModeParsing:
|
|||
assert _get_approval_mode() == "off"
|
||||
|
||||
|
||||
class TestSmartApproval:
|
||||
def test_smart_approval_uses_call_llm(self):
|
||||
response = SimpleNamespace(
|
||||
choices=[SimpleNamespace(message=SimpleNamespace(content="APPROVE"))]
|
||||
)
|
||||
with mock_patch("agent.auxiliary_client.call_llm", return_value=response) as mock_call:
|
||||
result = _smart_approve("python -c \"print('hello')\"", "script execution via -c flag")
|
||||
|
||||
assert result == "approve"
|
||||
mock_call.assert_called_once()
|
||||
assert mock_call.call_args.kwargs["task"] == "approval"
|
||||
assert mock_call.call_args.kwargs["temperature"] == 0
|
||||
assert mock_call.call_args.kwargs["max_tokens"] == 16
|
||||
|
||||
|
||||
class TestDetectDangerousRm:
|
||||
def test_rm_rf_detected(self):
|
||||
is_dangerous, key, desc = detect_dangerous_command("rm -rf /home/user")
|
||||
|
|
@ -820,4 +837,3 @@ class TestChmodExecuteCombo:
|
|||
dangerous, _, _ = detect_dangerous_command(cmd)
|
||||
assert dangerous is False
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue