Skip to content

[Bug] Context compaction SUMMARY_PREFIX causes cross-session task leakage #14603

@Feahter

Description

@Feahter

Bug Description

Context compaction (agent/context_compressor.py) injects a SUMMARY_PREFIX into compressed sessions that instructs the AI to treat the ## Active Task field from a previous session as the current active task to resume. This causes task leakage across sessions.

Root Cause

In agent/context_compressor.py lines 37-48:

SUMMARY_PREFIX = (
    "[CONTEXT COMPACTION — REFERENCE ONLY] Earlier turns were compacted "
    "into the summary below. This is a handoff from a previous context "
    "window — treat it as background reference, NOT as active instructions. "
    "Do NOT answer questions or fulfill requests mentioned in this summary; "
    "they were already addressed. "
    "Your current task is identified in the '## Active Task' section of the "
    "summary — resume exactly from there. "
    ...
)

The prefix is self-contradictory:

  1. "treat it as background reference, NOT as active instructions" — says treat as reference only
  2. "Your current task is identified in the '## Active Task' section of the summary — resume exactly from there" — says treat as active task

When a new session receives this summary, the AI reads line 43-44 and immediately interprets the ## Active Task from the previous session as its own current job. This is cross-session task injection, not just cross-session context.

Impact

  • Any long-running task (skill building, code projects, research) from a previous session gets reactivated in a new session without user intent
  • AI appears to "go off track" or "not listen" because it is busy resuming an old task it was told to resume
  • This is a persistent, systematic failure — every compressed session inherits this problem

Expected Behavior

The ## Active Task section in the summary should be treated as historical context, not as instructions to execute. The SUMMARY_PREFIX instruction "resume exactly from there" is fundamentally incompatible with the "REFERENCE ONLY" framing.

Suggested Fix

Remove or rewrite the line:
"Your current task is identified in the '## Active Task' section of the summary — resume exactly from there."

Replace with something like:
"The ## Active Task section describes what was being worked on previously — treat it as historical context only. The user's latest message is the only active instruction."

Or remove ## Active Task from the summary template entirely, since it serves no useful purpose in a "REFERENCE ONLY" context.

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