Repository navigation
Commit 42e22d4
committed
fix(heartbeat-filter): preserve HEARTBEAT_OK detection with reasoning/thinking blocks
The `isHeartbeatOkResponse` function was incorrectly rejecting assistant messages that contained non-text content blocks like "reasoning" or "thinking", even when the text content was a valid HEARTBEAT_OK acknowledgement.
This caused heartbeat transcript filtering to fail, leaving stale heartbeat prompts and acknowledgements in the model context, leading to:
- Major context size inflation
- Model confusion from tool call artifacts that should have been filtered
- 100% reproduction rate when heartbeat ACK contains reasoning blocks
The fix removes the overly broad `hasNonTextContent` check, allowing messages with reasoning/thinking blocks to be properly evaluated for HEARTBEAT_OK content.
Fixes issue #95796
## Evidence
### Before Fix
```ts
const message = {
role: "assistant",
content: [
{ type: "reasoning", text: "Let me check..." },
{ type: "text", text: "HEARTBEAT_OK" },
],
};
isHeartbeatOkResponse(message); // → false ❌ (should be true)
```
### After Fix
```ts
isHeartbeatOkResponse(message); // → true ✅
```
## Test Coverage
Added test case verifying HEARTBEAT_OK detection works correctly with:
- reasoning blocks
- thinking blocks
- output_text blocks (existing behavior preserved)1 parent ea56b13 commit 42e22d4
2 files changed
Lines changed: 31 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
138 | 168 | | |
139 | 169 | | |
140 | 170 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
| 339 | + | |
343 | 340 | | |
344 | 341 | | |
345 | 342 | | |
| |||
0 commit comments