fix: intercept [HEARTBEAT] prompt, suppress chatty non-urgent responses
This commit is contained in:
@@ -563,9 +563,21 @@ async def main(payload: dict, context):
|
|||||||
tools=all_tools,
|
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
|
final_message = None
|
||||||
try:
|
try:
|
||||||
async for event in agent.stream_async(payload.get('prompt', '')):
|
async for event in agent.stream_async(prompt):
|
||||||
if 'result' in event:
|
if 'result' in event:
|
||||||
final_message = event['result'].message
|
final_message = event['result'].message
|
||||||
yield event
|
yield event
|
||||||
|
|||||||
Reference in New Issue
Block a user