fix(gateway): count each bot message once in the loop guard and consume the author variable

The Telegram adapter asks the authorization check before dispatch, the ingress gate asks it
again, and the busy path asks a third time. Each call counted one loop-guard event, so a
Telegram bot tripped the budget after a third of the configured messages. The verdict now only
refuses a chat that is cooling down. The ingress gate counts an admitted bot message once.

`parse_turn_author` treats only booleans, integers and the strings true/1/yes as a bot flag,
and returns None for an author with neither id nor name. Names keep format characters and
non-breaking spaces so emoji sequences survive. The quiet one-shot pops HERMES_TURN_AUTHOR
before the turn so tool subprocesses do not inherit it. `max_events` must be a whole positive
number. Issue numbers move out of code comments.
This commit is contained in:
Erosika
2026-09-05 14:34:17 -04:00
committed by Teknium
parent 5bf69e963c
commit 55b3ea0b11
17 changed files with 241 additions and 224 deletions
+4 -3
View File
@@ -4056,13 +4056,14 @@ def _sync_cli_session_id_from_agent(cli) -> None:
def _run_quiet_single_query(cli, effective_query):
"""Quiet (-Q) one-shot turn: run, print the response (stderr for errors/session_id), then sys.exit with the automation exit code.
The turn's author comes from HERMES_TURN_AUTHOR, which only a bot-to-bot dispatcher sets on this subprocess."""
from agent.turn_author import turn_author_from_env
The turn's author comes from HERMES_TURN_AUTHOR. Only a bot-to-bot dispatcher sets it, and it is consumed
here so tool subprocesses do not inherit it."""
from agent.turn_author import take_turn_author_from_env
try:
result = cli.agent.run_conversation(
user_message=effective_query, conversation_history=cli.conversation_history,
turn_author=turn_author_from_env(),
turn_author=take_turn_author_from_env(),
)
except KeyboardInterrupt:
_emit_interrupted_session_end(cli, reason="keyboard_interrupt")