From: Anderson A. Giacomolli Date: Sun, 8 Nov 2026 14:57:43 +0000 (-0300) Subject: Give the WhatsApp batches to the agent X-Git-Url: https://git.giacomolli.uk/onechat/commitdiff_plain/56d959f2d573eef1be5c04d0bf1659fa30d36e7c?ds=sidebyside;hp=56d959f2d573eef1be5c04d0bf1659fa30d36e7c Give the WhatsApp batches to the agent The daemon reads the text messages of the private chats and the groups and gives them to the agent in batches. The messages of one chat form one batch while they are at most 20 seconds apart, for 2 minutes or 50 messages at the most, and a batch also closes after 20 quiet seconds in real time. The rule uses the WhatsApp times of the messages, so the catch-up after a stop gives the same batches as live messages. Each batch goes to the log as one work message that starts with [WhatsApp], with the chat, its ID for the later send tool, and the time, sender, and text of each message. It takes the path of the subagent reports: TurnLoop.Work logs it and, for a batch that needs the user, wakes the loop, so a batch that comes during a turn joins its next request. A batch starts a turn when it is private with a message of another person, or from a group with a message that mentions the user or replies to the user. Such a batch ends with a line that lets the agent end the turn with an empty reply. The chain already drops an empty reply, and Telegram drops the batches, so a batch that does not need the user gives no Telegram message. whatsapp/state.json keeps the batches that are not in the log. The library acknowledges a message only after the file holds it, and a batch leaves the file only after the log is durable, so a crash loses nothing and can repeat a batch once. A failed write stops the daemon. The own number never goes to the log: the messages of the user show as You, a mention of the user as @you, the number as OWN, and the chat of the user with itself is not read. The batches do not take media, reactions, edits, view-once and disappearing messages, or old history. Issue: 6f69ca1 ---