Skip to content

Fix duplicate session history on failed-run recovery - #1475

Closed
dajiaohuang wants to merge 2 commits into
usestrix:mainfrom
dajiaohuang:fix/salvage-session-dup
Closed

dajiaohuang wants to merge 2 commits into
usestrix:mainfrom
dajiaohuang:fix/salvage-session-dup

Conversation

@dajiaohuang

@dajiaohuang dajiaohuang commented Oct 7, 2026 •

Copy link
Copy Markdown

Withdrawn in favor of the earlier recovery work in #1311, which addresses #1310. The underlying duplication error remains real; this closure does not mean it is fixed on main.

At head 78b537c this patch compares the beginning of the replay, not its suffix. A normal SDK full-history replay includes the saved input, so prepending that input duplicates history. However, this patch still replaces the current session from an earlier snapshot and does not reconcile late persisted messages or make the rewrite atomic relative to SDK writers. Its existing first fixture also treats replay as new-items-only, unlike the supported full-history contract.

#1311 already covers the same recovery error, full-history/idempotence cases, late messages, and atomic SQLite reconciliation. No acceptance or execution of its tests is claimed here. No new tests, builds, runtime, installation, or CI runs were performed during this reassessment; the prior single targeted test pass is historical component evidence only. Branch and commits are retained.

…1310)

_salvage_stream_to_session previously did pre_run_items + replay, which
duplicated items when stream.to_input_list() already included the
pre-cycle input (the seeded initial_input is in both). Detect the overlap
and avoid duplication by checking if replay suffix matches pre_run_items.
@greptile-apps

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Fixes duplicate history in session recovery after run failure.

The overlap check should be corrected before merging because failed-run recovery still duplicates saved input.

Findings

  1. P1 Recovered history still repeats ▶
Fix with agent prompt
### Issue 1
strix/core/execution.py:175
`replay[-pre_len:]` checks the end of the history, but the overlap described by this fix is at the beginning. After a seeded run produces output and then fails, `pre_run_items = [initial_input]` and `replay = [initial_input, new_output]`. The comparison fails, so the fallback saves `[initial_input, initial_input, new_output]`. The revived agent still receives duplicate input.

Compare the beginning of `replay` instead. Add a test where `replay` includes saved input followed by new output; the existing test supplies only new output.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR tries to avoid repeating saved input when recovering a failed run.

  • Failed-run recovery saves history without repeating the opening input.

Reviews (1) · Last reviewed commit: "Fix duplicate session history on failed-..." · Reviewed by Greptile

Comment thread strix/core/execution.py Outdated
desired = list(pre_run_items) + replay
if len(desired) <= len(pre_run_items):
pre_len = len(pre_run_items)
if pre_len > 0 and len(replay) >= pre_len and replay[-pre_len:] == pre_run_items:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Recovered history still repeats

replay[-pre_len:] checks the end of the history, but the overlap described by this fix is at the beginning. After a seeded run produces output and then fails, pre_run_items = [initial_input] and replay = [initial_input, new_output]. The comparison fails, so the fallback saves [initial_input, initial_input, new_output]. The revived agent still receives duplicate input.

Compare the beginning of replay instead. Add a test where replay includes saved input followed by new output; the existing test supplies only new output.

Prompt To Fix With AI
This is a comment left during a code review.
Path: strix/core/execution.py
Line: 175

Comment:
**Recovered history still repeats**

`replay[-pre_len:]` checks the end of the history, but the overlap described by this fix is at the beginning. After a seeded run produces output and then fails, `pre_run_items = [initial_input]` and `replay = [initial_input, new_output]`. The comparison fails, so the fallback saves `[initial_input, initial_input, new_output]`. The revived agent still receives duplicate input.

Compare the beginning of `replay` instead. Add a test where `replay` includes saved input followed by new output; the existing test supplies only new output.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant