fix: interpolate responsePrefix template variables in heartbeat replies#43065
fix: interpolate responsePrefix template variables in heartbeat replies#43065yweiii wants to merge 1 commit into
Conversation
The heartbeat runner bypassed `resolveResponsePrefixTemplate()`, causing
template variables like `{model}` and `{provider}` to appear as literal
text in heartbeat alert replies.
Wire up `createReplyPrefixContext()` in `runHeartbeatOnce()` so the
`onModelSelected` callback populates model/provider context, then
interpolate the prefix template after the LLM responds.
Fixes openclaw#43064
Greptile SummaryThis PR fixes a bug where The fix wires up Key points:
Confidence Score: 4/5
Last reviewed commit: 6046c57 |
|
This pull request has been automatically marked as stale due to inactivity. |
|
Codex automated review: keeping this open. Keep this PR open. Current main still reads the heartbeat responsePrefix as a raw config string, does not pass onModelSelected into the heartbeat LLM call, and normalizes heartbeat alert replies with that raw prefix. The PR remains a focused implementation candidate for the same-author open bug report #43064, though it should be rebased onto the current lazy runtime boundary and its test coverage should avoid deep plugin internals if possible. Best possible solution: Keep this PR open for maintainer review or a rebased equivalent fix. The best implementation belongs in runHeartbeatOnce: create the reply prefix context for the heartbeat target, pass onModelSelected through getReplyFromConfig, resolve the raw responsePrefix with the populated prefixContext after the LLM call, and add focused heartbeat regression coverage that respects core/plugin boundaries. Keep #43064 open until a fix merges. What I checked:
Remaining risk / open question:
Codex Review notes: model gpt-5.5, reasoning high; reviewed against 5828dcdb05aa. |
Summary
responsePrefixtemplate variables ({model},{provider},{thinkingLevel}, etc.) instead of showing them as literal textcreateReplyPrefixContext()inrunHeartbeatOnce()soonModelSelectedpopulates model/provider context during the LLM callresolveResponsePrefixTemplate()to interpolate the prefix before passing it tonormalizeHeartbeatReply()Root cause
runHeartbeatOnce()resolvedresponsePrefixfrom config as the raw template string (e.g."{model}: ") and passed it directly tonormalizeHeartbeatReply()without interpolation. The normal reply path usescreateReplyPrefixContext()+resolveResponsePrefixTemplate()— the heartbeat path bypassed both.Changes
src/infra/heartbeat-runner.ts: ReplaceresolveEffectiveMessagesConfig()withcreateReplyPrefixContext()to get the raw prefix,onModelSelectedcallback, and mutableprefixContext. PassonModelSelectedtogetReplyFromConfig(). Interpolate the prefix after the LLM call.src/infra/heartbeat-runner.response-prefix-template.test.ts: 3 new tests verifyingonModelSelectedis passed togetReplyFromConfigin all heartbeat configurations.Test plan
pnpm build)pnpm check)responsePrefix: "{model}: ", trigger heartbeat alert, verify model name appears instead of{model}Fixes #43064