Skip to content

Commit 38a37ac

Browse files
authored
fix: add session cleanup to AgentDelegationTool (#15996)
Cleanup the session created by the `AgentDelegationTool` after the tool invocation has completed i.e. the response from the newly created session has been received. Fixes #15995
1 parent c88aa8c commit 38a37ac

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/ai-chat/src/browser/agent-delegation-tool.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ export class AgentDelegationTool implements ToolProvider {
149149
// Wait for completion to return the final result as tool output
150150
const result = await response.responseCompleted;
151151
const stringResult = result.response.asString();
152+
153+
// Clean up the session after completion
154+
const chatService = this.getChatService();
155+
chatService.deleteSession(newSession.id);
156+
152157
// Return the raw text to the top-level Agent, as a tool result
153158
return stringResult;
154159
} catch (completionError) {

0 commit comments

Comments
 (0)