Skip to content

fix(compaction): ignore blank summaries during rehydration#985

Open
sahniaditya007 wants to merge 1 commit into
getnao:mainfrom
sahniaditya007:fix/compaction-empty-text-blocks
Open

fix(compaction): ignore blank summaries during rehydration#985
sahniaditya007 wants to merge 1 commit into
getnao:mainfrom
sahniaditya007:fix/compaction-empty-text-blocks

Conversation

@sahniaditya007

@sahniaditya007 sahniaditya007 commented Jun 25, 2026

Copy link
Copy Markdown

Summary

Fixes #950.

When conversation compaction fails, an empty summary (summary: "") is persisted. During conversation reconstruction, this empty summary is treated as a valid compaction and reconstructed into an assistant message containing an empty text block.

Anthropic rejects requests containing empty text content blocks, causing the conversation to fail.

Changes

  • Ignore blank compaction summaries in findLastCompactionPart().
  • Add a regression test covering failed compactions with empty summaries.

Result

Failed compactions are treated as absent during rehydration, preventing invalid empty text blocks from being constructed while preserving the existing compaction metadata.

Testing

  • Added a regression test covering failed compactions with blank summaries.
  • Verified the new regression test passes.
  • Confirmed no unrelated files are modified by this PR.

Review in cubic

@github-actions

Copy link
Copy Markdown
Contributor

This PR was auto-closed. Only contributors approved with lgtm can open PRs. Open an issue first.

Maintainers review auto-closed issues daily. Issues that do not meet the quality bar in CONTRIBUTING.md will not be reopened or receive a reply.

If a maintainer replies lgtmi, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open.

See CONTRIBUTING.md.

@github-actions github-actions Bot closed this Jun 25, 2026
@Bl3f Bl3f reopened this Jun 25, 2026

@socallmebertille socallmebertille left a comment

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.

Thanks a lot for your contribution, I would appreciate it if you can take my next comment in consideration, run npx run prettier . to pass the check and then we'll be able to merge it ! 👍

Comment on lines +174 to +177
// Regression test for issue #950:
// When compaction fails, summary: '' is persisted to the DB.
// Re-hydrating that blank summary creates { type: 'text', text: '' } in the assistant message,
// which Anthropic rejects with "text content blocks must be non-empty".

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.

I think these comments are just a duplicate of the previous description so maybe you can remove them

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.

[bug] Compaction produces empty text blocks - breaks conversation

3 participants