diff --git a/src/lambdas/agent-runner/handler.py b/src/lambdas/agent-runner/handler.py index b8d39f5..bd26ccc 100644 --- a/src/lambdas/agent-runner/handler.py +++ b/src/lambdas/agent-runner/handler.py @@ -142,7 +142,10 @@ def handler(event, context): channel = first.get('channel', 'telegram') chat_id = first.get('chat_id', '') message_thread_id = first.get('message_thread_id') # int or None - actor_id = f"{channel}:{chat_id}" + # Use sender's user ID for identity (not chat_id, which is the group ID in group chats) + from_info_early = first.get('messages', [{}])[0] + sender_id = from_info_early.get('from_id') or chat_id + actor_id = f"{channel}:{sender_id}" # ── User registry ───────────────────────────────────────────────────── from_info = first.get('messages', [{}])[0]