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:
- "treat it as background reference, NOT as active instructions" — says treat as reference only
- "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.
Bug Description
Context compaction (
agent/context_compressor.py) injects aSUMMARY_PREFIXinto compressed sessions that instructs the AI to treat the## Active Taskfield from a previous session as the current active task to resume. This causes task leakage across sessions.Root Cause
In
agent/context_compressor.pylines 37-48:The prefix is self-contradictory:
When a new session receives this summary, the AI reads line 43-44 and immediately interprets the
## Active Taskfrom the previous session as its own current job. This is cross-session task injection, not just cross-session context.Impact
Expected Behavior
The
## Active Tasksection 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 Taskfrom the summary template entirely, since it serves no useful purpose in a "REFERENCE ONLY" context.