Skip to content

bug(compression): failed summaries should not discard conversation context #25585

@franksong2702

Description

@franksong2702

Problem

Automatic context compression can currently commit a destructive compaction even when the LLM summary could not be generated. In that failure mode, the compressor inserts a static "summary unavailable" marker and drops the middle turns anyway.

That is unsafe for long-running conversations: the visible transcript may still look recoverable, but the model-facing context can lose recent work while retaining an old protected head. This can make the agent drift back to stale topics after auto-compaction.

Expected behavior

If summary generation fails, compression should not discard the middle turns. The compressor should record the failure so callers can surface a warning, but it should leave the original context intact.

Proposed fix

  • Return the original message list when summary generation returns no summary.
  • Keep _last_summary_fallback_used, _last_summary_dropped_count, and _last_summary_error populated so UI/gateway callers can warn the user.
  • Do not increment compression_count on failed compression.
  • Update tests that previously expected static fallback truncation.

Verification

A focused regression PR will include tests covering the failed-summary path and related compressor/gateway compression paths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High — major feature broken, no workaroundcomp/agentCore agent loop, run_agent.py, prompt buildertype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions