@@ -2,10 +2,6 @@ import fs from "node:fs/promises";
22import os from "node:os" ;
33import path from "node:path" ;
44import { afterEach , beforeAll , beforeEach , describe , expect , it , vi } from "vitest" ;
5- import {
6- INTERNAL_RUNTIME_CONTEXT_BEGIN ,
7- INTERNAL_RUNTIME_CONTEXT_END ,
8- } from "../../agents/internal-runtime-context.js" ;
95import type { OpenClawConfig } from "../../config/config.js" ;
106import {
117 buildFastReplyCommandContext ,
@@ -203,7 +199,7 @@ describe("getReplyFromConfig fast test bootstrap", () => {
203199 expect ( vi . mocked ( runPreparedReplyMock ) ) . toHaveBeenCalledOnce ( ) ;
204200 } ) ;
205201
206- it ( "clears stale ack-only heartbeat pending delivery before replay " , async ( ) => {
202+ it ( "clears stale ack-only heartbeat pending delivery before running heartbeat " , async ( ) => {
207203 const home = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "openclaw-heartbeat-pending-clear-" ) ) ;
208204 const storePath = path . join ( home , "sessions.json" ) ;
209205 const sessionKey = "agent:main:telegram:123" ;
@@ -243,7 +239,7 @@ describe("getReplyFromConfig fast test bootstrap", () => {
243239 expect ( stored . pendingFinalDeliveryAttemptCount ) . toBeUndefined ( ) ;
244240 } ) ;
245241
246- it ( "uses ackMaxChars when replaying stale heartbeat pending delivery" , async ( ) => {
242+ it ( "keeps non-ack heartbeat pending delivery without direct replay " , async ( ) => {
247243 const home = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "openclaw-heartbeat-pending-replay-" ) ) ;
248244 const storePath = path . join ( home , "sessions.json" ) ;
249245 const sessionKey = "agent:main:telegram:123" ;
@@ -272,57 +268,15 @@ describe("getReplyFromConfig fast test bootstrap", () => {
272268
273269 await expect (
274270 getReplyFromConfig ( buildGetReplyCtx ( ) , { isHeartbeat : true } , cfg ) ,
275- ) . resolves . toEqual ( { text : "short " } ) ;
271+ ) . resolves . toEqual ( { text : "ok " } ) ;
276272
277273 const stored = JSON . parse ( await fs . readFile ( storePath , "utf8" ) ) [ sessionKey ] ;
278274 expect ( stored . pendingFinalDelivery ) . toBe ( true ) ;
279- expect ( stored . pendingFinalDeliveryText ) . toBe ( "short" ) ;
280- expect ( stored . pendingFinalDeliveryAttemptCount ) . toBe ( 1 ) ;
281- } ) ;
282-
283- it ( "sanitizes stale heartbeat pending delivery before replay" , async ( ) => {
284- const home = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "openclaw-heartbeat-pending-sanitize-" ) ) ;
285- const storePath = path . join ( home , "sessions.json" ) ;
286- const sessionKey = "agent:main:telegram:123" ;
287- await fs . writeFile (
288- storePath ,
289- JSON . stringify ( {
290- [ sessionKey ] : {
291- sessionId : "pending-dirty-remainder" ,
292- updatedAt : Date . now ( ) ,
293- pendingFinalDelivery : true ,
294- pendingFinalDeliveryText : [
295- "HEARTBEAT_OK" ,
296- INTERNAL_RUNTIME_CONTEXT_BEGIN ,
297- "internal recovery detail" ,
298- INTERNAL_RUNTIME_CONTEXT_END ,
299- "notify the user" ,
300- ] . join ( "\n" ) ,
301- } ,
302- } ) ,
303- "utf8" ,
304- ) ;
305- const cfg = withFastReplyConfig ( {
306- agents : {
307- defaults : {
308- model : "openai/gpt-5.5" ,
309- workspace : home ,
310- heartbeat : { ackMaxChars : 0 } ,
311- } ,
312- } ,
313- session : { store : storePath } ,
314- } as OpenClawConfig ) ;
315-
316- await expect (
317- getReplyFromConfig ( buildGetReplyCtx ( ) , { isHeartbeat : true } , cfg ) ,
318- ) . resolves . toEqual ( { text : "notify the user" } ) ;
319-
320- const stored = JSON . parse ( await fs . readFile ( storePath , "utf8" ) ) [ sessionKey ] ;
321- expect ( stored . pendingFinalDeliveryText ) . toBe ( "notify the user" ) ;
322- expect ( stored . pendingFinalDeliveryAttemptCount ) . toBe ( 1 ) ;
275+ expect ( stored . pendingFinalDeliveryText ) . toBe ( "HEARTBEAT_OK short" ) ;
276+ expect ( stored . pendingFinalDeliveryAttemptCount ) . toBeUndefined ( ) ;
323277 } ) ;
324278
325- it ( "does not replay stale heartbeat pending delivery when suppression is requested " , async ( ) => {
279+ it ( "does not replay stale heartbeat pending delivery" , async ( ) => {
326280 const home = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "openclaw-heartbeat-pending-suppress-" ) ) ;
327281 const storePath = path . join ( home , "sessions.json" ) ;
328282 const sessionKey = "agent:main:telegram:123" ;
@@ -351,12 +305,10 @@ describe("getReplyFromConfig fast test bootstrap", () => {
351305 } as OpenClawConfig ) ;
352306
353307 await expect (
354- getReplyFromConfig (
355- buildGetReplyCtx ( ) ,
356- { isHeartbeat : true , suppressPendingFinalDeliveryReplay : true } ,
357- cfg ,
358- ) ,
359- ) . resolves . toEqual ( { text : "ok" } ) ;
308+ getReplyFromConfig ( buildGetReplyCtx ( ) , { isHeartbeat : true } , cfg ) ,
309+ ) . resolves . toEqual ( {
310+ text : "ok" ,
311+ } ) ;
360312
361313 const stored = JSON . parse ( await fs . readFile ( storePath , "utf8" ) ) [ sessionKey ] ;
362314 expect ( stored . pendingFinalDelivery ) . toBe ( true ) ;
0 commit comments