GSD context lost after conversation compaction — missing session_compact hook
Problem
After planning or discussion reaches the context window limit and pi compacts the conversation, the compaction summary degrades to a generic "It looks like you're starting a fresh conversation" message. This loses all GSD context (active milestone, slice, task, phase) and forces the user to re-explain what they were working on.
Root Cause
File: extensions/gsd/register-hooks.js (between the session_before_compact handler ~line 504 and the message_update handler ~line 559)
GSD registers a session_before_compact hook that writes a snapshot to .gsd/last-snapshot.md, but does not register a session_compact handler to re-inject that state after compaction completes.
The before_agent_start hook re-injects the GSD system prompt on every turn, but the misleading compaction summary is already baked into the conversation history. The buildGuidedExecuteContextInjection context injection only fires for explicit task-execution prompts during phase === "executing" — it doesn't cover discussion or planning phases.
Other extensions (e.g., bg-shell) already use session_compact successfully to queue alerts that survive compaction via pushAlert.
// Current: only before_compact exists
pi.on("session_before_compact", async () => {
// writes snapshot to .gsd/last-snapshot.md
});
// Missing: no session_compact handler to re-inject context
// pi.on("session_compact", async () => { ... });Expected Behavior
GSD should register a session_compact handler that:
- Reads the just-written
.gsd/last-snapshot.mdsnapshot - Queues a context notification (via
pushAlertor equivalent) that re-injects the active milestone/slice/task state, phase, and key decisions into the post-compaction context
This ensures the agent resumes with full GSD awareness after compaction, regardless of which phase (discussion, planning, or execution) was active.
Alternative approach: Detect recent compaction in before_agent_start (snapshot file age < 30s) and inject the snapshot content directly into the system context message.
Environment
- GSD version: 3.0.0
- Trigger: Context compaction during discussion/planning phase
- Active milestone at time of issue: M001
- Active slice at time of issue: S06
Reproduction Steps
- Start a GSD session with an active milestone
- Have a long discussion or planning conversation that approaches the context limit
- When pi compacts the conversation, observe the summary loses all GSD context
- The agent behaves as if starting fresh, unaware of active work
Forensic Evidence
- No anomalies in activity logs or journal — the issue is in the compaction recovery path, not in auto-mode dispatch
session_before_compacthook exists and writes the snapshot correctlysession_compacthook is absent — no mechanism to re-inject the snapshot- bg-shell extension demonstrates the working pattern:
session_compact→pushAlert→ context survives
Auto-generated by /gsd forensics
Source: gsd-build/gsd-2