feat(FN-2232): check mailbox on every heartbeat run

- Fetch unread inbox messages whenever messageStore is available, not only wake-on-message triggers
- Include pending messages in execution prompts for task and no-task heartbeat runs across timer, assignment, and on-demand sources
- Extend heartbeat messaging tests to cover run-wide mailbox prefetch and read-marking behavior
- Document heartbeat mailbox checking semantics and messageResponseMode behavior in agents docs
- Replace Header mailbox badge class with existing header-badge style token
This commit is contained in:
Fusion
2026-04-22 02:22:52 -07:00
committed by gsxdsm
parent e2b69409be
commit 3afa378594
5 changed files with 273 additions and 34 deletions

View File

@@ -1171,12 +1171,12 @@ export class HeartbeatMonitor {
if (isNoTaskRun) {
// No-task heartbeat: agent has identity but no assigned task
// Fetch unread messages when woken by message trigger
if (triggerDetail === "wake-on-message" && this.messageStore) {
// Fetch unread messages when messageStore is available (for all trigger types)
if (this.messageStore) {
try {
pendingMessages = this.messageStore.getInbox(agentId, "agent", { read: false, limit: 10 });
} catch (inboxErr) {
heartbeatLog.warn(`Failed to fetch inbox messages for ${agentId} during wake-on-message: ${inboxErr instanceof Error ? inboxErr.message : String(inboxErr)}`);
heartbeatLog.warn(`Failed to fetch inbox messages for ${agentId}: ${inboxErr instanceof Error ? inboxErr.message : String(inboxErr)}`);
}
}
@@ -1226,12 +1226,12 @@ export class HeartbeatMonitor {
// Task-scoped heartbeat: agent has an assigned task
const taskTitle = taskDetail!.title ?? taskDetail!.description.slice(0, 100);
// Fetch unread messages when woken by message trigger
if (triggerDetail === "wake-on-message" && this.messageStore) {
// Fetch unread messages when messageStore is available (for all trigger types)
if (this.messageStore) {
try {
pendingMessages = this.messageStore.getInbox(agentId, "agent", { read: false, limit: 10 });
} catch (inboxErr) {
heartbeatLog.warn(`Failed to fetch inbox messages for ${agentId} during wake-on-message: ${inboxErr instanceof Error ? inboxErr.message : String(inboxErr)}`);
heartbeatLog.warn(`Failed to fetch inbox messages for ${agentId}: ${inboxErr instanceof Error ? inboxErr.message : String(inboxErr)}`);
}
}