fix(heartbeat): prevent internal reasoning leaks and finalization fallback in delivery

Three failure modes addressed:

1. Model reflects HEARTBEAT.md instructions back as output instead of
   executing them ("HEARTBEAT.md has active tasks listed...")
2. Model narrates decision logic ("Best judgment call: stay quiet")
3. Model produces empty output for silence, runner treats it as failure,
   finalization retry generates "couldn't produce a final answer" which
   gets delivered to the user

Changes:
- Add _is_deliverable() pre-filter in HeartbeatService._tick() that catches
  finalization fallback messages and leaked reasoning patterns before they
  reach the evaluator
- Wrap Phase 2 task input with a delivery-awareness preamble telling the
  model its output goes directly to the user's messaging app
- Add meta-reasoning suppression criterion to evaluator template

No changes to agent/loop.py, runner.py, providers, or config schema.
This commit is contained in:
hussein1362
2026-04-27 18:14:13 +08:00
committed by Xubin Ren
parent 9dc99d1b34
commit e72c415473
4 changed files with 293 additions and 9 deletions
+2
View File
@@ -6,6 +6,8 @@ Notify when the response contains actionable information, errors, completed deli
A user-scheduled reminder should usually notify even when the response is brief or mostly repeats the original reminder.
Suppress when the response is a routine status check with nothing new, a confirmation that everything is normal, or essentially empty.
Also suppress when the response contains meta-reasoning about the task itself — descriptions of internal instructions, references to configuration files (e.g. HEARTBEAT.md, AWARENESS.md), or decision logic about whether to notify the user. The user should never see the agent reasoning about whether to speak.
{% elif part == 'user' %}
## Original task
{{ task_context }}