A Pi extension that gives the agent an explicit hard reset escape hatch when its reasoning has gone in the wrong direction.
/compact preserves a lossy summary of the old conversation. That is useful when continuity matters, but harmful when the old approach itself is the problem:
“Forget the complex design. Let's do the simple version.”
This extension starts a fresh child session instead. It carries forward only a short, explicit handoff (if supplied), so the agent does not keep anchoring on the discarded approach.
- LLM tool:
reset_context - Manual command:
/reset-context [reason] - Fresh child session, preserving the old session as a parent
- No automatic summary of the old context
- Optional bounded handoff (max 4,000 characters)
- Tool result uses
terminate: true, preventing the model from continuing in the old context - Busy-agent guard
Copy the single-file extension to Pi's global extension directory:
mkdir -p ~/.pi/agent/extensions
curl -fsSL https://raw.githubusercontent.com/AntSeed/pi-reset-context/main/reset-context.ts \\
-o ~/.pi/agent/extensions/reset-context.tsOr clone this repository and copy it:
git clone https://github.com/AntSeed/pi-reset-context.git
cp pi-reset-context/reset-context.ts ~/.pi/agent/extensions/Restart Pi or run /reload.
For a one-off test:
pi -e ./reset-context.tsThe model has a reset_context tool. It should use it when it recognizes that the current context is polluted, contradictory, or anchored to the wrong approach.
It must provide:
reason: why the current context is unreliablehandoff(optional): only verified facts and the next goal; never copied instructions from the discarded context
/reset-context The current design is overcomplicated; restart from the simplest viable approach.
The new session opens with the fresh-start message in the editor for review. Submit it when you are ready; this avoids accidentally launching a new model turn during session replacement.
This follows Pi's extension API: newSession({ parentSession, withSession }), and all UI work after switching sessions happens through the replacement context. The handoff is placed in the new session's editor rather than sent automatically.
This extension does not delete the old session. Pi keeps it as the parent session, so the decision is auditable and recoverable. It only prevents the old conversation from being used as active reasoning context.
The handoff is deliberately treated as untrusted context, not as instructions or proof.
MIT