gateway: quiet Telegram operational chatter

This commit is contained in:
houenyang-momo
2026-05-23 16:32:18 +00:00
committed by Teknium
parent efa952531b
commit 60f84c6c28
7 changed files with 177 additions and 18 deletions
+39 -1
View File
@@ -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."""