From cf0466d96ca3ff6bdd519068794488c6dece2b0f Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Thu, 8 Jan 2026 03:39:58 +0100 Subject: [PATCH] fix(coding-agent): make ctx.shutdown() work from extension tools The tool execution context was created with a no-op shutdown handler. Now it delegates to ExtensionRunner.shutdown() which uses the handler set by the mode via initialize(). --- packages/coding-agent/src/core/extensions/runner.ts | 8 ++++++++ packages/coding-agent/src/core/sdk.ts | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/coding-agent/src/core/extensions/runner.ts b/packages/coding-agent/src/core/extensions/runner.ts index b417164a..79ea591b 100644 --- a/packages/coding-agent/src/core/extensions/runner.ts +++ b/packages/coding-agent/src/core/extensions/runner.ts @@ -288,6 +288,14 @@ export class ExtensionRunner { return undefined; } + /** + * Request a graceful shutdown. Called by extension tools and event handlers. + * The actual shutdown behavior is provided by the mode via initialize(). + */ + shutdown(): void { + this.shutdownHandler(); + } + private createContext(): ExtensionContext { return { ui: this.uiContext, diff --git a/packages/coding-agent/src/core/sdk.ts b/packages/coding-agent/src/core/sdk.ts index e04288bd..b8e6e75e 100644 --- a/packages/coding-agent/src/core/sdk.ts +++ b/packages/coding-agent/src/core/sdk.ts @@ -527,7 +527,9 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {} abort: () => { session.abort(); }, - shutdown: () => {}, + shutdown: () => { + extensionRunner?.shutdown(); + }, })); // Create tool registry mapping name -> tool (for extension getTools/setTools)