Add in-process dedup to prevent AgentCore retry duplicates
This commit is contained in:
@@ -67,7 +67,17 @@ def update_user_status(actor_id: str, name: str, status: str) -> None:
|
||||
)
|
||||
|
||||
|
||||
# Per-invocation dedup: track sent message hashes to prevent AgentCore retry duplicates
|
||||
_sent_hashes: set = set()
|
||||
|
||||
|
||||
def send_telegram_direct(chat_id: str, token: str, text: str) -> None:
|
||||
import hashlib
|
||||
h = hashlib.md5(f'{chat_id}:{text}'.encode()).hexdigest()[:12]
|
||||
if h in _sent_hashes:
|
||||
print(f'[agent-runner] dedup: skipping duplicate message (hash={h})')
|
||||
return
|
||||
_sent_hashes.add(h)
|
||||
url = f'https://api.telegram.org/bot{token}/sendMessage'
|
||||
data = json.dumps({'chat_id': chat_id, 'text': text}).encode()
|
||||
req = urllib.request.Request(url, data=data, headers={'Content-Type': 'application/json'})
|
||||
|
||||
Reference in New Issue
Block a user