Skip to content

fix: Fix sliding window compactor to also retain historical user-assistant turns if the budget allows - #12270

Merged
sjrl merged 29 commits into
mainfrom
fix-sliding-window
Aug 11, 2026
Merged

fix: Fix sliding window compactor to also retain historical user-assistant turns if the budget allows#12270
sjrl merged 29 commits into
mainfrom
fix-sliding-window

Conversation

@sjrl

@sjrl sjrl commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Related Issues

  • fixes #issue-number

Proposed Changes:

The first built-in strategy, SlidingWindowCompactor, preserves leading system messages, the latest user task, and as much complete recent conversation as the target allows. NEW: It removes earlier user/assistant turns as whole units first. Only when removing all earlier turns is insufficient does it remove individual Agent steps from the current task. It replaces removed history with a short omission note.

How did you test it?

New tests

Notes for the reviewer

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

@sjrl sjrl self-assigned this Aug 7, 2026
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
haystack-docs Ignored Ignored Preview Aug 11, 2026 8:54am

Request Review

@github-actions github-actions Bot added topic:tests type:documentation Improvements on the docs labels Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/hooks/compaction
  sliding_window.py
Project Total  

This report was generated by python-coverage-comment-action

Comment thread haystack/hooks/compaction/sliding_window.py
@sjrl
sjrl requested a review from anakin87 August 7, 2026 13:34
Comment thread haystack/hooks/compaction/sliding_window.py Outdated
Comment thread haystack/hooks/compaction/sliding_window.py Outdated
Comment thread haystack/hooks/compaction/sliding_window.py
@sjrl
sjrl marked this pull request as ready for review August 10, 2026 10:59
@sjrl
sjrl requested a review from a team as a code owner August 10, 2026 10:59
@sjrl
sjrl requested review from anakin87 and davidsbatista and removed request for a team and davidsbatista August 10, 2026 10:59

@anakin87 anakin87 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just one little comment left

@sjrl
sjrl force-pushed the fix-sliding-window branch from 85bd98e to 1a971d5 Compare August 11, 2026 07:29
@sjrl

sjrl commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

@anakin87 sorry for the messed up history, I was trying out the new github stacked PR feature and in the end it wasn't quite working

@sjrl
sjrl enabled auto-merge (squash) August 11, 2026 08:58
@sjrl
sjrl merged commit b4e262f into main Aug 11, 2026
25 checks passed
@sjrl
sjrl deleted the fix-sliding-window branch August 11, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants