fix(heartbeat): rotate to fresh session on autocompact thrash (#29)#202
Open
om952 wants to merge 2 commits into
Open
fix(heartbeat): rotate to fresh session on autocompact thrash (#29)#202om952 wants to merge 2 commits into
om952 wants to merge 2 commits into
Conversation
…sh stop reason + session rotation guard Tracks upstream paperclipai#6736. Changes: - Add `autocompact_thrash` as a first-class HeartbeatRunStopReason - Export `isAutocompactThrashError()` to detect thrash error strings - Update `inferHeartbeatRunStopReason()` to classify thrash before adapter_failed catch-all - Restructure `evaluateSessionCompaction()` to always fetch >=1 prior run, then force session rotation when the most-recent run was a thrash failure (covers both new typed stopReason and legacy error string detection) - Fix `finalizeAgentStatus()` to accept subprocess exit code; transition agent from error -> idle when subprocess exits 0 even if run was pre-terminated as failed - Filter mentioned skill IDs through `isUuidLike()` to avoid slug-mention false positives - Unit tests for thrash detection classifier and process-recovery exit-code-0 override Closes OpenScanAI#29
…anAI#29) Ports upstream PR paperclipai#6736 behavior: when a heartbeat run fails because the adapter session is autocompact-thrashing, force a session rotation instead of resuming the poisoned session. Detects both the typed `resultStopReason` and legacy error-string markers. - Move `evaluateSessionCompactionFromRuns` to module top-level so it can be exported cleanly and unit-tested. - Remove unrelated `maxConsecutiveAdapterFailed` session-compaction branch. - Add regression coverage in `heartbeat-process-recovery.test.ts` that seeds a known task session, simulates the thrash failure, and proves the recovery run receives a fresh session and does not retry the poisoned one. Closes OpenScanAI#29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports upstream PR paperclipai#6736 behavior: when a heartbeat run fails because the adapter session is autocompact-thrashing, force a session rotation instead of resuming the poisoned session.
Changes:
evaluateSessionCompaction(detectsresultStopReason === "autocompact_thrash"and legacy error strings).evaluateSessionCompactionFromRunsto module top-level as a clean export.maxConsecutiveAdapterFailed/countConsecutiveAdapterFailedRunssession-compaction code.heartbeat-process-recovery.test.tsthat seeds a known task session, simulates the thrash failure, and proves the recovery run receives a fresh session and no second wasted compaction attempt is recorded.Verification:
npx vitest run server/src/__tests__/heartbeat-process-recovery.test.ts— 46/46 passnpx vitest run server/src/__tests__/heartbeat-workspace-session.test.ts— 38/38 passnpx vitest run server/src/services/heartbeat-stop-metadata.test.ts— 8/8 passpnpm build— passespnpm -r typecheck— clean except pre-existing unrelatedplugin-host-services.tserrorCloses #29