Skip to content

Context compression causes historical conversations to be inserted into current conversation #9096

@atop0914

Description

@atop0914

Bug Description

When context compression is triggered, the agent repeatedly inserts historical conversation content into the current conversation. This causes the conversation history to become duplicated and mixed in the active context.

Steps to Reproduce

  1. Have a conversation that exceeds the context window threshold
  2. Trigger context compression (e.g., by reaching 85% of max context length)
  3. Observe that historical messages are re-inserted into the current active conversation

Expected Behavior

After compression, the context should contain only the compressed summary and the most recent messages, without duplicating historical content.

Actual Behavior

Every time compression runs, the agent inserts the full historical conversation into the current context, leading to:

  • Message duplication
  • Inflated context size
  • Degraded conversation quality

Additional Context

This appears to be related to the built-in context compression mechanism. The compression seems to work correctly in terms of counting tokens, but the output is being appended rather than replacing the original messages.

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