Merge branch 'main' of github.com:NousResearch/hermes-agent into bb/gui

This commit is contained in:
Brooklyn Nicholson
2026-05-18 02:23:49 -05:00
20 changed files with 1745 additions and 1128 deletions
+56
View File
@@ -989,6 +989,28 @@ class TestBuildSystemPrompt:
# Should contain current date info like "Conversation started:"
assert "Conversation started:" in prompt
def test_datetime_is_date_only_not_minute_precision(self, agent):
"""Timestamp must be date-only (no HH:MM) so the system prompt
stays byte-stable for the full day. Minute precision invalidates
prefix-cache KV on every rebuild path (compression, fresh-agent
gateway turns, session resume without a stored prompt)."""
prompt = agent._build_system_prompt()
# Find the line and strip it for inspection
for line in prompt.splitlines():
if line.startswith("Conversation started:"):
# Must NOT contain AM/PM indicator (minute precision had %I:%M %p)
assert " AM" not in line and " PM" not in line, (
f"Timestamp line has time-of-day, breaks daily cache stability: {line!r}"
)
# Must NOT contain a colon followed by two digits (HH:MM pattern)
import re as _re
assert not _re.search(r":\d{2}", line), (
f"Timestamp line has HH:MM, breaks daily cache stability: {line!r}"
)
break
else:
assert False, "Expected a 'Conversation started:' line in the system prompt"
def test_includes_nous_subscription_prompt(self, agent, monkeypatch):
monkeypatch.setattr(run_agent, "build_nous_subscription_prompt", lambda tool_names: "NOUS SUBSCRIPTION BLOCK")
prompt = agent._build_system_prompt()
@@ -1074,6 +1096,40 @@ class TestToolUseEnforcementConfig:
prompt = agent._build_system_prompt()
assert TOOL_USE_ENFORCEMENT_GUIDANCE not in prompt
def test_auto_injects_for_grok(self):
"""xAI Grok / xai-oauth models hit the same enforcement path as GPT."""
from agent.prompt_builder import TOOL_USE_ENFORCEMENT_GUIDANCE
agent = self._make_agent(model="x-ai/grok-4.3", tool_use_enforcement="auto")
prompt = agent._build_system_prompt()
assert TOOL_USE_ENFORCEMENT_GUIDANCE in prompt
def test_auto_injects_execution_guidance_for_grok(self):
"""Grok also gets OPENAI_MODEL_EXECUTION_GUIDANCE (verification,
mandatory_tool_use, act_dont_ask). Same failure modes as GPT in
practice — claims completion without tool calls, suggests workarounds
instead of using existing tools.
"""
from agent.prompt_builder import OPENAI_MODEL_EXECUTION_GUIDANCE
agent = self._make_agent(model="x-ai/grok-4.3", tool_use_enforcement="auto")
prompt = agent._build_system_prompt()
assert OPENAI_MODEL_EXECUTION_GUIDANCE in prompt
def test_auto_injects_execution_guidance_for_xai_oauth_model(self):
"""xai-oauth bare model names (no slash) also match the grok pattern."""
from agent.prompt_builder import OPENAI_MODEL_EXECUTION_GUIDANCE
agent = self._make_agent(model="grok-4.3", tool_use_enforcement="auto")
prompt = agent._build_system_prompt()
assert OPENAI_MODEL_EXECUTION_GUIDANCE in prompt
def test_auto_does_not_inject_execution_guidance_for_claude(self):
"""Sanity: execution guidance stays off for non-targeted families."""
from agent.prompt_builder import OPENAI_MODEL_EXECUTION_GUIDANCE
agent = self._make_agent(
model="anthropic/claude-sonnet-4", tool_use_enforcement="auto"
)
prompt = agent._build_system_prompt()
assert OPENAI_MODEL_EXECUTION_GUIDANCE not in prompt
def test_true_forces_for_all_models(self):
from agent.prompt_builder import TOOL_USE_ENFORCEMENT_GUIDANCE
agent = self._make_agent(model="anthropic/claude-sonnet-4", tool_use_enforcement=True)