From 223836f41a8c408c31c5b211a0573d1de993aef9 Mon Sep 17 00:00:00 2001 From: GRayHook Date: Thu, 18 Jun 2026 23:00:25 +0700 Subject: [PATCH] Phase 15: wire mid-turn steer delivery on session_compact defer path When agent is not idle after auto compaction, deliver pending reinject immediately via steer instead of waiting for before_agent_start. Co-authored-by: Cursor --- src/index.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/index.ts b/src/index.ts index 244fbbc..bde8cea 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,6 +24,7 @@ import { import { applyPendingReinjectAfterCompact, clearPendingReinjectOnUserPrompt, + deliverDeferredReinjectSteer, planDeferredReinject, planReinject, sendImmediateReinjectAllFollowUp, @@ -101,6 +102,8 @@ export default function skillReinject(pi: ExtensionAPI): void { const skills = resolveRegisteredSkills(ctx.cwd, registeredSkills); const branch = ctx.sessionManager.getBranch(); compactionRuntime.lastCompactionFirstKeptEntryId = event.compactionEntry.firstKeptEntryId; + compactionRuntime.lastCompactionEntryId = event.compactionEntry.id; + compactionRuntime.deferredDeliveredForCompactionId = null; const trackedNames = state.skills.map((skill) => skill.name); const keptEntries = getKeptEntries(branch, event.compactionEntry.firstKeptEntryId); const keptPresent = skillsPresentInKeptWindow(keptEntries, trackedNames); @@ -126,6 +129,17 @@ export default function skillReinject(pi: ExtensionAPI): void { ); if (deliveryMode === "defer") { + if (shouldReinject && planned.length > 0 && !ctx.isIdle()) { + deliverDeferredReinjectSteer( + pi, + state, + settings, + skills, + compactionRuntime, + event.compactionEntry.id, + ctx, + ); + } persistState(); return; }