mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-13 03:52:00 +00:00
fix(gateway): honor configured goal turn budget
This commit is contained in:
parent
0efc547962
commit
4d4807585a
2 changed files with 85 additions and 18 deletions
62
tests/gateway/test_goal_max_turns_config.py
Normal file
62
tests/gateway/test_goal_max_turns_config.py
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
import pytest
|
||||
|
||||
from gateway.config import GatewayConfig, Platform, PlatformConfig
|
||||
from gateway.platforms.base import MessageEvent, MessageType
|
||||
from gateway.run import GatewayRunner
|
||||
from gateway.session import SessionSource
|
||||
from hermes_cli import goals
|
||||
|
||||
|
||||
class _FakeSessionEntry:
|
||||
session_id = "sid-gateway-goal-config"
|
||||
|
||||
|
||||
class _FakeSessionStore:
|
||||
def __init__(self):
|
||||
self.entry = _FakeSessionEntry()
|
||||
|
||||
def get_or_create_session(self, source):
|
||||
return self.entry
|
||||
|
||||
def _generate_session_key(self, source):
|
||||
return "agent:main:discord:channel:goal-config"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_gateway_goal_uses_goals_max_turns_from_full_config(tmp_path, monkeypatch):
|
||||
"""Gateway /goal should honor top-level goals.max_turns from config.yaml."""
|
||||
home = tmp_path / ".hermes"
|
||||
home.mkdir()
|
||||
(home / "config.yaml").write_text("goals:\n max_turns: 7\n", encoding="utf-8")
|
||||
monkeypatch.setenv("HERMES_HOME", str(home))
|
||||
goals._DB_CACHE.clear()
|
||||
|
||||
runner = object.__new__(GatewayRunner)
|
||||
runner.config = GatewayConfig(
|
||||
platforms={Platform.DISCORD: PlatformConfig(enabled=True, token="token")}
|
||||
)
|
||||
runner.session_store = _FakeSessionStore()
|
||||
runner.adapters = {}
|
||||
runner._queued_events = {}
|
||||
|
||||
event = MessageEvent(
|
||||
text="/goal ship the benchmark",
|
||||
message_type=MessageType.TEXT,
|
||||
source=SessionSource(
|
||||
platform=Platform.DISCORD,
|
||||
chat_id="chat-goal-config",
|
||||
chat_type="channel",
|
||||
user_id="user-goal-config",
|
||||
),
|
||||
message_id="msg-goal-config",
|
||||
)
|
||||
|
||||
response = await GatewayRunner._handle_goal_command(runner, event)
|
||||
|
||||
try:
|
||||
assert "⊙ Goal set (7-turn budget): ship the benchmark" in response
|
||||
state = goals.GoalManager("sid-gateway-goal-config").state
|
||||
assert state is not None
|
||||
assert state.max_turns == 7
|
||||
finally:
|
||||
goals._DB_CACHE.clear()
|
||||
Loading…
Add table
Add a link
Reference in a new issue