-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
Heartbeat isolatedSession=true replays prior heartbeat context, causing deterministic overflow/restart loop #84218
Copy link
Copy link
Open
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Description
Metadata
Metadata
Assignees
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Priority
None yet
Summary
Heartbeat runs configured with
isolatedSession=trueandlightContext=truecan still receive a large replay of prior heartbeat context. The docs describeisolatedSession: trueas a "fresh session each run (no conversation history)", but the compiled prompt can include context-engine summaries and prior assistant/tool heartbeat outputs associated with the stable heartbeat session key.On our production VPS this became a deterministic loop:
agent:trent:main:heartbeatollama/nemotron-3-nano:30bIn one 6-hour window on this deployment alone, we observed approximately 280 overflow prechecks and 70 restart cycles. The first visible crossing of the nemotron context limit was no later than 2026-05-17T22:15:27Z, and the pattern continued afterward until we mitigated locally by moving the heartbeat lane to a larger-context model and reducing cadence.
Repro config shape
A single agent heartbeat is enough when the model context window is smaller than the accumulated replay:
{ "agents": { "list": [ { "id": "trent", "heartbeat": { "every": "5m", "model": "ollama/nemotron-3-nano:30b", "isolatedSession": true, "lightContext": true, "target": "none" } } ] } }The same class should reproduce with any model around a ~112K usable prompt window or smaller once enough heartbeat output has accumulated.
Documentation vs observed behavior
Docs say:
isolatedSession: true= "fresh session each run (no conversation history)"lightContext: true= "only inject HEARTBEAT.md from bootstrap files"Observed behavior:
isolatedSession=truecreates a new session id, but not a fresh model context.lightContext=truetrims bootstrap files only; it does not stop context-engine/session replay of prior heartbeat summaries, assistant outputs, or tool results.Source-read root cause
From reading the installed 2026.5.18 dist source, the substrate appears to:
<base>:heartbeatresolveCronSession(... forceNew: true ...)to create a new session idSessionKey: runSessionKey, whererunSessionKeyis the stable isolated heartbeat session keybootstrapContextMode="lightweight"forlightContext=trueSo the session id is fresh, but context is still rebuilt against a stable heartbeat session key that can hydrate old heartbeat activity.
Evidence from compiled context
A failing heartbeat trajectory
context.compiledevent showed:The actual heartbeat transcript .jsonl was absent after precheck failure; the evidence was in the trajectory file.
Expected behavior
When
isolatedSession=true, a heartbeat tick should be truly bounded/fresh by default:HEARTBEAT.md, current time, pending system events/commitments, and explicitly configured bounded contextIf preserving some heartbeat history is desired, it should be opt-in and bounded.
Actual behavior
Prior heartbeat activity is replayed into the next heartbeat prompt despite a fresh session id. Once the replay exceeds the model context window, reactive compaction/restart does not solve it because the same oversized context is regenerated on retry.
Impact
A quiet maintenance feature can become a load loop:
/readyzfrom event-loop delay/utilizationSuggested fix
Please add one of:
isolatedSession=trueenforce no prior heartbeat history by default.heartbeat.maxHistoryMessages,heartbeat.maxContextMessages, orheartbeat.replayHistory=false.Also consider preventing
notify=false/ no-change heartbeat outputs from being promoted into future heartbeat context.