mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-07 08:02:23 +00:00
gateway: quiet Telegram operational chatter
This commit is contained in:
parent
efa952531b
commit
60f84c6c28
7 changed files with 177 additions and 18 deletions
|
|
@ -378,8 +378,15 @@ class TestBusySessionAck:
|
|||
assert adapter._send_with_retry.call_count == 2
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_includes_status_detail(self):
|
||||
async def test_includes_status_detail_when_opted_in(self, monkeypatch):
|
||||
"""Ack message should include iteration and tool info when available."""
|
||||
import gateway.run as _gr
|
||||
|
||||
monkeypatch.setattr(
|
||||
_gr,
|
||||
"_load_gateway_config",
|
||||
lambda: {"display": {"platforms": {"telegram": {"busy_ack_detail": True}}}},
|
||||
)
|
||||
runner, sentinel = _make_runner()
|
||||
runner._busy_input_mode = "interrupt"
|
||||
adapter = _make_adapter()
|
||||
|
|
@ -408,6 +415,37 @@ class TestBusySessionAck:
|
|||
assert "terminal" in content # current tool
|
||||
assert "10 min" in content # elapsed
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_telegram_omits_status_detail_by_default(self):
|
||||
"""Telegram busy acks stay concise unless busy_ack_detail is enabled."""
|
||||
runner, sentinel = _make_runner()
|
||||
runner._busy_input_mode = "interrupt"
|
||||
adapter = _make_adapter()
|
||||
|
||||
event = _make_event(text="yo")
|
||||
sk = build_session_key(event.source)
|
||||
|
||||
agent = MagicMock()
|
||||
agent.get_activity_summary.return_value = {
|
||||
"api_call_count": 21,
|
||||
"max_iterations": 60,
|
||||
"current_tool": "terminal",
|
||||
"last_activity_ts": time.time(),
|
||||
"last_activity_desc": "terminal",
|
||||
"seconds_since_activity": 0.5,
|
||||
}
|
||||
runner._running_agents[sk] = agent
|
||||
runner._running_agents_ts[sk] = time.time() - 600
|
||||
runner.adapters[event.source.platform] = adapter
|
||||
|
||||
await runner._handle_active_session_busy_message(event, sk)
|
||||
|
||||
content = adapter._send_with_retry.call_args.kwargs.get("content", "")
|
||||
assert "Interrupting current task" in content
|
||||
assert "21/60" not in content
|
||||
assert "terminal" not in content
|
||||
assert "10 min" not in content
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_draining_still_works(self):
|
||||
"""Draining case should still produce the drain-specific message."""
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ class TestResolveDisplaySetting:
|
|||
|
||||
# Empty config — should get built-in defaults
|
||||
config = {}
|
||||
# Telegram tier_high override: "new" (not "all") to reduce edit
|
||||
# pressure during streaming on Telegram's ~1 edit/s flood envelope.
|
||||
assert resolve_display_setting(config, "telegram", "tool_progress") == "new"
|
||||
# Telegram is a mobile inbox by default — final-answer-first unless
|
||||
# explicitly configured otherwise.
|
||||
assert resolve_display_setting(config, "telegram", "tool_progress") == "off"
|
||||
# Email defaults to tier_minimal → "off"
|
||||
assert resolve_display_setting(config, "email", "tool_progress") == "off"
|
||||
|
||||
|
|
@ -180,12 +180,11 @@ class TestPlatformDefaults:
|
|||
"""Built-in defaults reflect platform capability tiers."""
|
||||
|
||||
def test_high_tier_platforms(self):
|
||||
"""Discord defaults to 'all' tool progress; Telegram is in tier_high
|
||||
but overrides tool_progress to 'new' (less edit pressure)."""
|
||||
"""Discord defaults to 'all'; Telegram defaults quiet for mobile."""
|
||||
from gateway.display_config import resolve_display_setting
|
||||
|
||||
# Telegram: tier_high member with tool_progress="new" override.
|
||||
assert resolve_display_setting({}, "telegram", "tool_progress") == "new"
|
||||
# Telegram: tier_high transport, but quiet mobile default.
|
||||
assert resolve_display_setting({}, "telegram", "tool_progress") == "off"
|
||||
# Discord: pure tier_high.
|
||||
assert resolve_display_setting({}, "discord", "tool_progress") == "all"
|
||||
|
||||
|
|
@ -229,6 +228,36 @@ class TestPlatformDefaults:
|
|||
|
||||
assert resolve_display_setting({}, "telegram", "streaming") is None
|
||||
|
||||
def test_telegram_mobile_chatter_defaults_off(self):
|
||||
"""Telegram suppresses operational chat noise unless opted in."""
|
||||
from gateway.display_config import resolve_display_setting
|
||||
|
||||
assert resolve_display_setting({}, "telegram", "interim_assistant_messages") is False
|
||||
assert resolve_display_setting({}, "telegram", "long_running_notifications") is False
|
||||
assert resolve_display_setting({}, "telegram", "busy_ack_detail") is False
|
||||
assert resolve_display_setting({}, "discord", "interim_assistant_messages") is True
|
||||
assert resolve_display_setting({}, "discord", "long_running_notifications") is True
|
||||
assert resolve_display_setting({}, "discord", "busy_ack_detail") is True
|
||||
|
||||
def test_telegram_mobile_chatter_can_opt_in(self):
|
||||
"""Per-platform config can re-enable Telegram status chatter."""
|
||||
from gateway.display_config import resolve_display_setting
|
||||
|
||||
config = {
|
||||
"display": {
|
||||
"platforms": {
|
||||
"telegram": {
|
||||
"interim_assistant_messages": True,
|
||||
"long_running_notifications": "yes",
|
||||
"busy_ack_detail": "on",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assert resolve_display_setting(config, "telegram", "interim_assistant_messages") is True
|
||||
assert resolve_display_setting(config, "telegram", "long_running_notifications") is True
|
||||
assert resolve_display_setting(config, "telegram", "busy_ack_detail") is True
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Config migration: tool_progress_overrides → display.platforms
|
||||
|
|
|
|||
|
|
@ -784,12 +784,13 @@ async def test_run_agent_surfaces_real_interim_commentary(monkeypatch, tmp_path)
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_run_agent_surfaces_interim_commentary_by_default(monkeypatch, tmp_path):
|
||||
async def test_run_agent_surfaces_interim_commentary_when_globally_enabled(monkeypatch, tmp_path):
|
||||
adapter, result = await _run_with_agent(
|
||||
monkeypatch,
|
||||
tmp_path,
|
||||
CommentaryAgent,
|
||||
session_id="sess-commentary-default-on",
|
||||
session_id="sess-commentary-global-on",
|
||||
config_data={"display": {"interim_assistant_messages": True}},
|
||||
)
|
||||
|
||||
assert any(call["content"] == "I'll inspect the repo first." for call in adapter.sent)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue