refactor: simplify message tool suppress — bool check instead of target tracking

This commit is contained in:
Re-bin
2026-02-27 02:27:18 +00:00
parent ac1c40db91
commit 29e6709e26
3 changed files with 58 additions and 169 deletions

View File

@@ -20,7 +20,7 @@ class MessageTool(Tool):
self._default_channel = default_channel
self._default_chat_id = default_chat_id
self._default_message_id = default_message_id
self._turn_sends: list[tuple[str, str]] = []
self._sent_in_turn: bool = False
def set_context(self, channel: str, chat_id: str, message_id: str | None = None) -> None:
"""Set the current message context."""
@@ -34,11 +34,7 @@ class MessageTool(Tool):
def start_turn(self) -> None:
"""Reset per-turn send tracking."""
self._turn_sends.clear()
def get_turn_sends(self) -> list[tuple[str, str]]:
"""Get (channel, chat_id) targets sent in the current turn."""
return list(self._turn_sends)
self._sent_in_turn = False
@property
def name(self) -> str:
@@ -105,7 +101,8 @@ class MessageTool(Tool):
try:
await self._send_callback(msg)
self._turn_sends.append((channel, chat_id))
if channel == self._default_channel and chat_id == self._default_chat_id:
self._sent_in_turn = True
media_info = f" with {len(media)} attachments" if media else ""
return f"Message sent to {channel}:{chat_id}{media_info}"
except Exception as e: