bot_peer_notices.py 853 B

1234567891011121314151617
  1. """What the runtime itself may send to the author of an inbound message (#137027).
  2. A bot peer reads every message in its chat as a new inbound turn, so a runtime-written notice (busy
  3. ack, redirect, status, progress, warnings, failure copy, delegation failures) sent to it starts a
  4. turn there, whose reply starts one here. The model's own reply is the only thing a bot peer gets.
  5. Every automatic-notice egress asks ``automatic_notices_allowed``; none re-derives the rule.
  6. """
  7. from __future__ import annotations
  8. from typing import Any
  9. def automatic_notices_allowed(source: Any) -> bool:
  10. """False when the message came from a known bot (``SessionSource.is_bot``, a bool: the platform's
  11. bot flag or the adapter's ``bot_users`` opt-in). Anything but a real ``True`` is not a known bot."""
  12. return getattr(source, "is_bot", False) is not True