Skip to content

[BUG] Context compaction causes duplicate responses after compression #11475

@Hommchen

Description

@Hommchen

Bug Description

After context compaction, the agent repeats responses to old messages that were already processed hours ago.

Root Cause

When context is compacted, old messages are replaced with a summary. The system injects an "Active Task" field pointing to the last task being worked on. However, this task may be hours old.

The agent's instruction says "Respond ONLY to the latest user message" but the summary's "Active Task" appears as the latest content, causing the agent to continue working on tasks from hours ago as if they were new.

Expected Behavior

After compaction, the agent should only respond to user messages that arrive AFTER the compaction. Old tasks in the summary should be marked as "already completed" and not re-processed.

Proposed Fix

Add a compaction boundary flag in run_agent.py:

# After compaction, inject:
COMPACTED_BOUNDARY = True
LAST_PROCESSED_TURN = {last_turn_id}

The agent prompt should be updated to:

  • If COMPACTED_BOUNDARY == True, ignore summary content and only respond to messages arriving after the compaction point.
  • Treat all summary content as "already processed."

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