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:
@@ -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)}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user