Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: add session cleanup to AgentDelegationTool
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
  • Loading branch information
tortmayr committed Jul 13, 2025
commit 5c14bff5abe859f0516a351068cd6e9f43dbc020
5 changes: 5 additions & 0 deletions packages/ai-chat/src/browser/agent-delegation-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ export class AgentDelegationTool implements ToolProvider {
// Wait for completion to return the final result as tool output
const result = await response.responseCompleted;
const stringResult = result.response.asString();

// Clean up the session after completion
const chatService = this.getChatService();
chatService.deleteSession(newSession.id);

// Return the raw text to the top-level Agent, as a tool result
return stringResult;
} catch (completionError) {
Expand Down
Loading