fix(extensions): emit compaction failed for extensions (#8241)

* fix(extensions): emit compaction failed

* changelog yeet
This commit is contained in:
Cristina Poncela Cubeiro 2026-08-17 13:10:08 +02:00 • committed by GitHub
parent df018b6020
commit a6b1dbceb1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 139 additions and 10 deletions

View file

@ -330,7 +330,8 @@ user sends another prompt ◄─────────────────
/compact or auto-compaction
├─► session_before_compact (can cancel or customize)
└─► session_compact
├─► session_compact (success)
└─► session_compact_failed (failure or abort)
/tree navigation
├─► session_before_tree (can cancel or customize)
@ -448,7 +449,7 @@ pi.on("session_before_fork", async (event, ctx) => {
After a successful fork or clone, pi emits `session_shutdown` for the old extension instance, reloads and rebinds extensions for the new session, then emits `session_start` with `reason: "fork"` and `previousSessionFile`.
Do cleanup work in `session_shutdown`, then reestablish any in-memory state in `session_start`.
#### session_before_compact / session_compact
#### session_before_compact / session_compact / session_compact_failed
Fired on compaction. See [compaction.md](compaction.md) for details.
@ -479,6 +480,14 @@ pi.on("session_compact", async (event, ctx) => {
// event.reason - "manual" (/compact), "threshold", or "overflow"
// event.willRetry - whether the aborted turn is retried after compaction (overflow recovery)
});
pi.on("session_compact_failed", async (event, ctx) => {
// event.reason - "manual" (/compact), "threshold", or "overflow"
// event.errorMessage - present for non-abort failures
// event.aborted - true for cancelled/aborted compactions
// event.willRetry - whether the aborted turn would have retried after compaction
// event.fromExtension - whether extension-provided compaction content was being used
});
```
#### session_before_tree / session_tree