diff --git a/agentclaw/app/agent_claw_main/main.py b/agentclaw/app/agent_claw_main/main.py index e4b26cf..b591f10 100644 --- a/agentclaw/app/agent_claw_main/main.py +++ b/agentclaw/app/agent_claw_main/main.py @@ -563,9 +563,21 @@ async def main(payload: dict, context): tools=all_tools, ) + # Intercept heartbeat: replace bare [HEARTBEAT] with a strict-format instruction. + # Agent-runner suppresses replies that start with HEARTBEAT_OK, so only real alerts reach Telegram. + prompt = payload.get('prompt', '') + if prompt.strip() == '[HEARTBEAT]': + prompt = ( + 'HEARTBEAT CHECK: Silently check for anything urgent Daniel should know about ' + '(calendar events starting within 2 hours, unread urgent emails, overdue reminders). ' + 'Do NOT narrate your checking process. ' + 'If nothing is urgent: reply with the single word HEARTBEAT_OK and nothing else. ' + 'If something IS urgent: reply with 2-3 lines max summarising only the urgent items.' + ) + final_message = None try: - async for event in agent.stream_async(payload.get('prompt', '')): + async for event in agent.stream_async(prompt): if 'result' in event: final_message = event['result'].message yield event