From cb835c7ea98345d51508b944f57c252c7c55e503 Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Sun, 2 Aug 2026 12:23:29 +0800 Subject: [PATCH] fix(acp): keep per-session teardown failure reasons in the aggregate log MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The connection-close teardown path threw a bare `AggregateError` whose message counts the failed sessions, and its only production consumer logs through `String(error)` — which renders the message alone. Compared with the previous `Promise.all` behavior, every actual disposal failure reason disappeared from operational logs. Join the per-session reasons into the aggregate message, matching the subagent seam's own aggregate disposal messages, and pin the reason in the dispose spec's warning assertion. --- packages/acp/acp/src/index.ts | 10 +++++++++- packages/acp/acp/tests/dispose.spec.ts | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/acp/acp/src/index.ts b/packages/acp/acp/src/index.ts index 0a2f7f7f68..7af26b594a 100644 --- a/packages/acp/acp/src/index.ts +++ b/packages/acp/acp/src/index.ts @@ -368,7 +368,15 @@ export function apply(ctx: Context, config: AcpConfig): void { if (result.status === 'rejected') failures.push(result.reason as unknown) } if (failures.length > 0) { - throw new AggregateError(failures, `ACP agent teardown failed for ${failures.length} session(s)`) + // The only production consumer logs this error through `String`, which + // renders the message alone — without the joined reasons, per-session + // disposal failures would vanish from operational logs. Join them like + // the subagent seam's own aggregate disposal messages. + const detail = failures.map(failure => String(failure)).join('; ') + throw new AggregateError( + failures, + `ACP agent teardown failed for ${failures.length} session(s): ${detail}`, + ) } })() return quiescing diff --git a/packages/acp/acp/tests/dispose.spec.ts b/packages/acp/acp/tests/dispose.spec.ts index 5f6b5babd5..0eea014eeb 100644 --- a/packages/acp/acp/tests/dispose.spec.ts +++ b/packages/acp/acp/tests/dispose.spec.ts @@ -131,7 +131,8 @@ describe('ACP connection ownership', () => { releaseSecond.resolve(undefined) await vi.waitFor(() => { - expect(warnings.some(warning => warning.includes('ACP agent teardown failed for 1 session(s)'))).toBe(true) + expect(warnings.some(warning => + warning.includes('ACP agent teardown failed for 1 session(s): Error: first session cleanup failed'))).toBe(true) expect(harness!.ctx.agents.get(SessionId(first.sessionId))).toBeUndefined() expect(harness!.ctx.agents.get(SessionId(second.sessionId))).toBeUndefined() })