Commit 5e565fd
fix: preserve stale shell fingerprint across CompleteResponse (#574)
## What
One-line fix: `ClearProcessingState` now uses `preserveCarryOver: true`
when clearing deferred idle tracking, matching what `SendPromptAsync`
already does.
## Why
When the CLI leaks stale shell entries in `backgroundTasks` across turns
(issue #573), the carryover detection
(`ShouldIgnoreCarryOverShellOnlyTasks`) should recognize them as old and
skip the IDLE-DEFER. But `ClearProcessingState` was wiping the
fingerprint and firstSeenTicks on every turn completion, so the next
turn saw the same stale shells as brand-new and deferred for ~10 minutes
every time.
## The bug path
1. Turn completes → `CompleteResponse` → `ClearProcessingState` → wipes
`DeferredBackgroundTaskFingerprint` and `FirstSeenTicks`
2. User sends new message → `SendPromptAsync` calls
`ClearDeferredIdleTracking(preserveCarryOver: true)` — but the data is
already gone
3. `session.idle` arrives with `shells=2` (stale from CLI)
4. `RefreshDeferredBackgroundTaskTracking` sees `previousTicks=0`, sets
`firstSeenTicks = now`
5. `ShouldIgnoreCarryOverShellOnlyTasks` checks `firstSeenTicks <
processingStartedAt` — **false** (both are ~now)
6. IDLE-DEFER kicks in, watchdog eventually force-completes after ~10
min
## The fix
`preserveCarryOver: true` in `ClearProcessingState` keeps the shell
fingerprint and age across the complete→send boundary, so step 5
correctly detects the shells as carried over and skips the defer.
## Testing
- 3323/3323 tests pass
- Specifically verified `BackgroundTasksIdleTests`,
`ProcessingWatchdogTests`, and `ChatExperienceSafetyTests` (254 targeted
tests)
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 66af028 commit 5e565fd
2 files changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
797 | 797 | | |
798 | 798 | | |
799 | 799 | | |
800 | | - | |
| 800 | + | |
801 | 801 | | |
802 | 802 | | |
803 | 803 | | |
| |||
0 commit comments