惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
腾讯CDC
阮一峰的网络日志
阮一峰的网络日志
GbyAI
GbyAI
B
Blog RSS Feed
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
Last Week in AI
Last Week in AI
F
Fortinet All Blogs
云风的 BLOG
云风的 BLOG
N
Netflix TechBlog - Medium
G
Google Developers Blog
博客园_首页
有赞技术团队
有赞技术团队
V
V2EX
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
aimingoo的专栏
aimingoo的专栏
月光博客
月光博客
Hugging Face - Blog
Hugging Face - Blog
The GitHub Blog
The GitHub Blog
S
SegmentFault 最新的问题

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(agents): stop injecting heartbeat system prompt on no...
stainlu · 2026-04-25 · via Recent Commits to openclaw:main

File tree

  • src/agents/pi-embedded-runner/run

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,32 @@

1+

import { describe, expect, it } from "vitest";

2+

import { shouldInjectHeartbeatPromptForTrigger } from "./trigger-policy.js";

3+
4+

describe("shouldInjectHeartbeatPromptForTrigger", () => {

5+

it("injects the heartbeat prompt on heartbeat-triggered runs", () => {

6+

expect(shouldInjectHeartbeatPromptForTrigger("heartbeat")).toBe(true);

7+

});

8+
9+

// Regression: the heartbeat system prompt instructs the model to reply

10+

// exactly "HEARTBEAT_OK" when nothing is pending. If that prompt leaks into

11+

// a user-triggered turn, the model can pattern-match the literal HEARTBEAT_OK

12+

// token (which the delivery runtime then suppresses, so the user sees

13+

// silence) or hallucinate a "[object Object]" serialization error as it

14+

// tries to reconcile the heartbeat instruction with a real user message.

15+

// See issue #69079 and its parent #50797.

16+

it.each([

17+

["user"] as const,

18+

["manual"] as const,

19+

["cron"] as const,

20+

["memory"] as const,

21+

["overflow"] as const,

22+

])("does not inject the heartbeat prompt on %s-triggered runs", (trigger) => {

23+

expect(shouldInjectHeartbeatPromptForTrigger(trigger)).toBe(false);

24+

});

25+
26+

it("does not inject the heartbeat prompt when no trigger is supplied", () => {

27+

// Defense-in-depth: if a new call site lands without a trigger, it should

28+

// fall through to the safe default rather than spuriously injecting

29+

// heartbeat instructions.

30+

expect(shouldInjectHeartbeatPromptForTrigger(undefined)).toBe(false);

31+

});

32+

});

Original file line numberDiff line numberDiff line change

@@ -4,13 +4,21 @@ type EmbeddedRunTriggerPolicy = {

44

injectHeartbeatPrompt: boolean;

55

};

66
7+

// The heartbeat system prompt tells the model to reply exactly "HEARTBEAT_OK"

8+

// when nothing needs attention. It is only meaningful on heartbeat-triggered

9+

// runs; injecting it on user/manual/memory/overflow runs confuses smaller

10+

// models into pattern-matching the HEARTBEAT_OK output on real user messages

11+

// (delivery then suppresses the "reply", so the user sees silence) or into

12+

// fabricating "[object Object]" serialization errors as they try to reconcile

13+

// the heartbeat instruction with a non-heartbeat turn. See issue #69079 and

14+

// its parent #50797. Default off; heartbeat trigger explicitly opts in.

715

const DEFAULT_EMBEDDED_RUN_TRIGGER_POLICY: EmbeddedRunTriggerPolicy = {

8-

injectHeartbeatPrompt: true,

16+

injectHeartbeatPrompt: false,

917

};

1018
1119

const EMBEDDED_RUN_TRIGGER_POLICY: Partial<Record<EmbeddedRunTrigger, EmbeddedRunTriggerPolicy>> = {

12-

cron: {

13-

injectHeartbeatPrompt: false,

20+

heartbeat: {

21+

injectHeartbeatPrompt: true,

1422

},

1523

};

1624