Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gateway/src/config/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const DEFAULT_CONFIG: GsvConfig = {
bindings: [],
defaultHeartbeat: {
every: "30m",
prompt: "Read HEARTBEAT.md if it exists in your workspace. Follow it strictly. Do not infer or repeat old tasks from prior chats. If nothing needs attention, reply HEARTBEAT_OK.",
prompt: "Follow the HEARTBEAT.md instructions below. Do not infer or repeat old tasks from prior chats. If nothing needs attention, reply HEARTBEAT_OK.",
target: "last",
activeHours: { start: "08:00", end: "23:00" },
},
Expand Down
11 changes: 9 additions & 2 deletions gateway/src/gateway/do.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3576,9 +3576,11 @@ export class Gateway extends DurableObject<Env> {
}
}

// Load HEARTBEAT.md content (used for skip check and prompt injection)
const heartbeatFile = await loadHeartbeatFile(this.env.STORAGE, agentId);

// Skip check 2: Empty HEARTBEAT.md file (unless manual trigger)
if (reason !== "manual") {
const heartbeatFile = await loadHeartbeatFile(this.env.STORAGE, agentId);
if (
!heartbeatFile.exists ||
isHeartbeatFileEmpty(heartbeatFile.content)
Expand Down Expand Up @@ -3681,7 +3683,12 @@ export class Gateway extends DurableObject<Env> {
agentId, // For deduplication lookup
};
}
const prompt = config.prompt;
// Inject HEARTBEAT.md content directly into the prompt so the agent
// always sees the latest version, even in a persistent session.
let prompt = config.prompt;
if (heartbeatFile.exists && heartbeatFile.content.trim()) {
prompt += `\n\n---\nHEARTBEAT.md contents:\n${heartbeatFile.content.trim()}`;
}
const tools = JSON.parse(JSON.stringify(this.getAllTools()));
const runtimeNodes = JSON.parse(
JSON.stringify(this.getRuntimeNodeInventory()),
Expand Down