From 62354c272c81623155829e573dbf0294ed047d15 Mon Sep 17 00:00:00 2001 From: minpeter Date: Fri, 24 Jul 2026 20:43:05 +0900 Subject: [PATCH] fix(coding-agent): expose failed compaction attempts --- packages/coding-agent/src/core/agent-session.ts | 3 ++- packages/coding-agent/src/core/changes.md | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/coding-agent/src/core/agent-session.ts b/packages/coding-agent/src/core/agent-session.ts index 590d0bcbb..c878481a4 100644 --- a/packages/coding-agent/src/core/agent-session.ts +++ b/packages/coding-agent/src/core/agent-session.ts @@ -4232,6 +4232,8 @@ export class AgentSession { if (reason === "overflow") this._overflowRecoveryAttempted = false; return false; } + if (!this._ownsCompactionController(autoCompactionController, "auto")) return false; + this._emit({ type: "compaction_start", reason }); const authResult = await this._modelRuntime.getAuth(this.model); if (!this._ownsCompactionController(autoCompactionController, "auto")) return false; @@ -4250,7 +4252,6 @@ export class AgentSession { return false; } if (!this._ownsCompactionController(autoCompactionController, "auto")) return false; - this._emit({ type: "compaction_start", reason }); const execution = await this._executeCompaction({ controller: autoCompactionController, diff --git a/packages/coding-agent/src/core/changes.md b/packages/coding-agent/src/core/changes.md index ec5e08714..d9286017a 100644 --- a/packages/coding-agent/src/core/changes.md +++ b/packages/coding-agent/src/core/changes.md @@ -8,6 +8,8 @@ controller at operation start, rejects stale completion/feedback, and retains the terminal result until another operation begins. Feedback-only aborts publish one terminal event, and accepted completions publish their terminal event before `session_compact` handlers can begin a fresh operation. +- Owned automatic compaction attempts publish `compaction_start` before authentication/preparation so an early + preparation failure does not invisibly consume the one overflow retry attempt. - Durable append now rejects a generation whose message revision or agent-message snapshot changed during preparation or summary generation (`stale-revision`), preserving intervening context without duplicate replay. - Required compaction uses one provider-admission gate for normal prompts, extension-triggered turns, and every next