Skip to content

Commit 6181ddd

Browse files
committed
fix: prevent heartbeat runner from leaking private replies when response tool not used (fixes #94053)
Add early return when usesHeartbeatResponseTool is true but heartbeatToolResponse is falsy. Treat as silent heartbeat to comply with message_tool_only privacy mode.
1 parent 7048906 commit 6181ddd

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

‎src/infra/heartbeat-runner.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,6 +1849,34 @@ export async function runHeartbeatOnce(opts: {
18491849
const ackMaxChars = resolveHeartbeatAckMaxChars(cfg, heartbeat);
18501850
const responsePrefix = resolveHeartbeatResponsePrefix();
18511851

1852+
if (usesHeartbeatResponseTool && !heartbeatToolResponse) {
1853+
await restoreHeartbeatUpdatedAt({
1854+
storePath,
1855+
sessionKey,
1856+
updatedAt: previousUpdatedAt,
1857+
});
1858+
const okSent = await maybeSendHeartbeatOk();
1859+
emitHeartbeatEvent({
1860+
status: "ok-***",
1861+
reason: opts.reason,
1862+
preview: replyPayload?.text?.slice(0, 200) ?? "",
1863+
durationMs: Date.now() - startedAt,
1864+
channel: delivery.channel !== "none" ? delivery.channel : undefined,
1865+
accountId: delivery.accountId,
1866+
silent: !okSent,
1867+
indicatorType: visibility.useIndicator ? resolveIndicatorType("ok-***") : undefined,
1868+
});
1869+
await markCommitmentsStatus({
1870+
cfg,
1871+
ids: dueCommitmentIds,
1872+
status: "dismissed",
1873+
nowMs: startedAt,
1874+
});
1875+
await updateTaskTimestamps();
1876+
consumeInspectedSystemEvents();
1877+
return { status: "ran", durationMs: Date.now() - startedAt };
1878+
}
1879+
18521880
if (heartbeatToolResponse && !heartbeatToolResponse.notify) {
18531881
await restoreHeartbeatUpdatedAt({
18541882
storePath,

0 commit comments

Comments
 (0)