@theia/ai-chat 1.76.0-next.18 → 1.76.0-next.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,6 +16,12 @@ export declare class AgentDelegationTool implements ToolProvider {
16
16
  invocation: ChatRequestInvocation;
17
17
  } | undefined;
18
18
  private delegateToAgent;
19
+ /**
20
+ * Makes the given task context the session's task context, replacing a previously set one.
21
+ * `addVariables` deduplicates on variable id *and* argument, so adding a different task context
22
+ * id would otherwise leave the session with both in its system prompt.
23
+ */
24
+ private setTaskContext;
19
25
  /**
20
26
  * Sets up all event bubbling from a delegated child session to the parent session:
21
27
  * - Interaction forwarding: child interactionNeeded events are forwarded to the parent response
@@ -1 +1 @@
1
- {"version":3,"file":"agent-delegation-tool.d.ts","sourceRoot":"","sources":["../../src/browser/agent-delegation-tool.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAuD,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAChH,OAAO,EAAc,OAAO,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAEH,gBAAgB,EAKhB,WAAW,EAMX,qBAAqB,EAGxB,MAAM,WAAW,CAAC;AAGnB,qBACa,mBAAoB,YAAW,YAAY;IACpD,MAAM,CAAC,EAAE,SAAgC;IAEzC,SAAS,CAAC,QAAQ,CAAC,kBAAkB;gBAA6B,MAAM;oBAAc,qBAAqB;OAAM;IAGjH,SAAS,CAAC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;IAG/D,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,WAAW,CAAC;IAGrD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEnC,OAAO,IAAI,WAAW;IAqCtB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,qBAAqB,CAAA;KAAE,GAAG,SAAS;YAItF,eAAe;IAmK7B;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;CAgCpC"}
1
+ {"version":3,"file":"agent-delegation-tool.d.ts","sourceRoot":"","sources":["../../src/browser/agent-delegation-tool.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAuD,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAChH,OAAO,EAAc,OAAO,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAEH,gBAAgB,EAMhB,WAAW,EAQX,qBAAqB,EAGxB,MAAM,WAAW,CAAC;AAGnB,qBACa,mBAAoB,YAAW,YAAY;IACpD,MAAM,CAAC,EAAE,SAAgC;IAEzC,SAAS,CAAC,QAAQ,CAAC,kBAAkB;gBAA6B,MAAM;oBAAc,qBAAqB;OAAM;IAGjH,SAAS,CAAC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;IAG/D,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,WAAW,CAAC;IAGrD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEnC,OAAO,IAAI,WAAW;IA8CtB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,qBAAqB,CAAA;KAAE,GAAG,SAAS;YAItF,eAAe;IAuN7B;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAatB;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;CAgCpC"}
@@ -34,9 +34,12 @@ let AgentDelegationTool = class AgentDelegationTool {
34
34
  id: AgentDelegationTool_1.ID,
35
35
  name: AgentDelegationTool_1.ID,
36
36
  description: 'Delegate a task or question to a specific AI agent. IMPORTANT: When you delegate a task or question to a specific AI agent using this tool, ' +
37
- 'remember that each sub-agent operates solely within its specialized capabilities and tools and does not have access to previous conversation context ' +
38
- ' or external systems. Therefore, it is crucial to provide all necessary context and detailed information directly within your request to ensure accurate ' +
39
- 'and effective task completion. ' +
37
+ 'remember that each sub-agent operates solely within its specialized capabilities and tools and, unless you resume a previous delegation via sessionId, ' +
38
+ 'does not have access to previous conversation context or external systems. Therefore, it is crucial to provide all necessary context and detailed ' +
39
+ 'information directly within your request to ensure accurate and effective task completion. ' +
40
+ 'Each result ends with a "[delegation sessionId: <id>]" line. To send a follow-up request to the same agent with its previous conversation retained ' +
41
+ '(e.g. to request fixes after reviewing its result), pass that id as sessionId. Prefer resuming for follow-ups on the same task; ' +
42
+ 'start a fresh session (omit sessionId) for unrelated tasks, as a resumed session grows with every round. ' +
40
43
  'You may optionally pass a taskContextId to make a specific task context (e.g. a plan) available to the delegated agent via its system prompt.',
41
44
  parameters: {
42
45
  type: 'object',
@@ -53,6 +56,12 @@ let AgentDelegationTool = class AgentDelegationTool {
53
56
  type: 'string',
54
57
  description: 'Optional task context ID to make available to the delegated agent. The agent will see the task context in its system prompt.',
55
58
  },
59
+ sessionId: {
60
+ type: 'string',
61
+ description: 'Optional ID of a previous delegation session to continue, as reported in the "[delegation sessionId: <id>]" line of an earlier result. ' +
62
+ 'The delegated agent keeps its previous conversation context, so you do not need to repeat context you already sent it. ' +
63
+ 'Only a session that you delegated yourself can be resumed, and the agentId must match the original delegation.',
64
+ },
56
65
  },
57
66
  required: ['agentId', 'prompt'],
58
67
  },
@@ -71,7 +80,7 @@ let AgentDelegationTool = class AgentDelegationTool {
71
80
  }
72
81
  try {
73
82
  const args = JSON.parse(arg_string);
74
- const { agentId, prompt, taskContextId } = args;
83
+ const { agentId, prompt, taskContextId, sessionId } = args;
75
84
  if (!agentId || !prompt) {
76
85
  const errorMsg = 'Both agentId and prompt parameters are required.';
77
86
  this.logger.error(errorMsg, { agentId, prompt });
@@ -87,109 +96,162 @@ let AgentDelegationTool = class AgentDelegationTool {
87
96
  this.logger.error(errorMsg);
88
97
  return errorMsg;
89
98
  }
90
- let newSession;
99
+ let session;
91
100
  let childModelDisposable;
92
- try {
101
+ if (sessionId) {
93
102
  const chatService = this.getChatService();
94
- // Store the current active session to restore it after delegation
95
- const currentActiveSession = chatService.getActiveSession();
96
- newSession = chatService.createSession(undefined, { focus: false }, agent);
97
- // Set root session ID to enable task context sharing across delegation chains
98
- // Root is either the current root (for nested delegation) or current session (for first-level delegation)
99
- const rootId = ctx.rootSessionId || ctx.request.session.id;
100
- newSession.rootSessionId = rootId;
101
- newSession.model.rootSessionId = rootId;
102
- // Track the immediate parent (the delegating session) so the UI can render the full
103
- // delegation hierarchy, not just a flat list under the root.
104
- const parentId = ctx.request.session.id;
105
- newSession.parentSessionId = parentId;
106
- newSession.model.parentSessionId = parentId;
107
- if (taskContextId) {
108
- newSession.model.context.addVariables({
109
- variable: task_context_variable_1.TASK_CONTEXT_VARIABLE,
110
- arg: taskContextId
111
- });
103
+ // Restore from storage if necessary: delegated sessions are auto-saved, so after a reload the
104
+ // delegating session's history still carries the id while the session itself is no longer in memory.
105
+ const existingSession = await chatService.getOrRestoreSession(sessionId);
106
+ if (!existingSession) {
107
+ const errorMsg = `Delegation session '${sessionId}' not found. It may have been deleted. ` +
108
+ 'Send the request again without sessionId to start a fresh session — the agent will not have any prior context.';
109
+ // warn, not error: a stale session id is expected in a normal agentic loop (e.g. the user deleted the session)
110
+ this.logger.warn(errorMsg);
111
+ return errorMsg;
112
112
  }
113
- // Immediately restore the original active session to avoid confusing the user
114
- if (currentActiveSession) {
115
- chatService.setActiveSession(currentActiveSession.id, { focus: false });
113
+ if (existingSession.parentSessionId !== ctx.request.session.id) {
114
+ // Without this, any session id would be accepted, including an unrelated top-level user chat,
115
+ // and the delegated request would be injected into it.
116
+ const errorMsg = `Delegation session '${sessionId}' was not delegated by this session and cannot be resumed here. ` +
117
+ 'Only pass a sessionId reported by one of your own earlier delegations, or omit it to start a fresh session.';
118
+ this.logger.error(errorMsg);
119
+ return errorMsg;
116
120
  }
117
- // Setup bubbling of child session events to parent session
118
- childModelDisposable = this.setupChildSessionBubbling(newSession.model, ctx.request.session, ctx.response);
119
- }
120
- catch (sessionError) {
121
- const errorMsg = `Failed to create chat session for agent '${agentId}': ${sessionError instanceof Error ? sessionError.message : sessionError}`;
122
- this.logger.error(errorMsg, sessionError);
123
- return errorMsg;
124
- }
125
- // Send the request
126
- const chatRequest = {
127
- text: `@${agentId} ${prompt}`,
128
- };
129
- let response;
130
- try {
131
- if (ctx.cancellationToken?.isCancellationRequested) {
132
- return 'Operation cancelled by user';
121
+ if (common_1.ChatSessionStatus.isInProgress(existingSession.model.status)) {
122
+ const errorMsg = `Delegation session '${sessionId}' is still processing a previous request. ` +
123
+ 'Wait for its result before sending a follow-up, or omit sessionId to start a fresh session.';
124
+ // warn, not error: expected when the caller issues parallel requests against the same session
125
+ this.logger.warn(errorMsg);
126
+ return errorMsg;
133
127
  }
134
- const chatService = this.getChatService();
135
- response = await chatService.sendRequest(newSession.id, chatRequest);
136
- if (ctx.cancellationToken) {
137
- ctx.cancellationToken.onCancellationRequested(async () => {
138
- if (response) {
139
- (await response?.requestCompleted).cancel();
140
- }
141
- });
128
+ if (existingSession.pinnedAgent && existingSession.pinnedAgent.id !== agentId) {
129
+ const errorMsg = `Delegation session '${sessionId}' belongs to agent '${existingSession.pinnedAgent.id}', not '${agentId}'. ` +
130
+ 'Pass the matching agentId, or omit sessionId to start a fresh session.';
131
+ this.logger.error(errorMsg);
132
+ return errorMsg;
142
133
  }
134
+ // Deliberately keep rootSessionId/parentSessionId as set at creation time; a resumed
135
+ // session stays attached to its original delegation hierarchy.
136
+ if (taskContextId) {
137
+ this.setTaskContext(existingSession.model.context, taskContextId);
138
+ }
139
+ session = existingSession;
140
+ // Re-establish bubbling for this request; the previous disposable was disposed when the
141
+ // original delegation completed, and the parent request/response are new objects now.
142
+ childModelDisposable = this.setupChildSessionBubbling(existingSession.model, ctx.request.session, ctx.response);
143
143
  }
144
- catch (sendError) {
145
- const errorMsg = `Failed to send request to agent '${agentId}': ${sendError instanceof Error ? sendError.message : sendError}`;
146
- this.logger.error(errorMsg, sendError);
147
- return errorMsg;
148
- }
149
- if (response) {
150
- // Store the invocation in the registry so the renderer can access it
151
- if (ctx.toolCallId) {
152
- this.pendingDelegations.set(ctx.toolCallId, {
153
- prompt,
154
- invocation: response
155
- });
156
- // Clean up when the delegated session is deleted
144
+ else {
145
+ try {
157
146
  const chatService = this.getChatService();
158
- const toolCallId = ctx.toolCallId;
159
- const sessionEventListener = chatService.onSessionEvent(event => {
160
- if (event.type === 'deleted' && event.sessionId === newSession.id) {
161
- this.pendingDelegations.delete(toolCallId);
162
- sessionEventListener.dispose();
163
- }
164
- });
147
+ // Store the current active session to restore it after delegation
148
+ const currentActiveSession = chatService.getActiveSession();
149
+ const newSession = chatService.createSession(undefined, { focus: false }, agent);
150
+ // Set root session ID to enable task context sharing across delegation chains
151
+ // Root is either the current root (for nested delegation) or current session (for first-level delegation)
152
+ const rootId = ctx.rootSessionId || ctx.request.session.id;
153
+ newSession.rootSessionId = rootId;
154
+ newSession.model.rootSessionId = rootId;
155
+ // Track the immediate parent (the delegating session) so the UI can render the full
156
+ // delegation hierarchy, not just a flat list under the root.
157
+ const parentId = ctx.request.session.id;
158
+ newSession.parentSessionId = parentId;
159
+ newSession.model.parentSessionId = parentId;
160
+ if (taskContextId) {
161
+ newSession.model.context.addVariables({
162
+ variable: task_context_variable_1.TASK_CONTEXT_VARIABLE,
163
+ arg: taskContextId
164
+ });
165
+ }
166
+ // Immediately restore the original active session to avoid confusing the user
167
+ if (currentActiveSession) {
168
+ chatService.setActiveSession(currentActiveSession.id, { focus: false });
169
+ }
170
+ // Setup bubbling of child session events to parent session
171
+ childModelDisposable = this.setupChildSessionBubbling(newSession.model, ctx.request.session, ctx.response);
172
+ session = newSession;
165
173
  }
166
- try {
167
- // Wait for completion to return the final result as tool output
168
- const result = await response.responseCompleted;
169
- const filteredContent = result.response.content.filter(c => !common_1.ThinkingChatResponseContent.is(c) && !common_1.ToolCallChatResponseContent.is(c));
170
- const stringResult = filteredContent
171
- .map(c => common_1.ChatResponseContent.hasAsString(c) ? c.asString() : undefined)
172
- .filter((text) => text !== undefined && text !== '')
173
- .join('\n\n');
174
- // Clean up the parent-child link after completion (event bubbling is no longer needed)
175
- childModelDisposable?.dispose();
176
- // Return the raw text to the top-level Agent, as a tool result
177
- return stringResult;
174
+ catch (sessionError) {
175
+ const errorMsg = `Failed to create chat session for agent '${agentId}': ${sessionError instanceof Error ? sessionError.message : sessionError}`;
176
+ this.logger.error(errorMsg, sessionError);
177
+ return errorMsg;
178
178
  }
179
- catch (completionError) {
180
- if (completionError instanceof Error &&
181
- completionError.message.includes('cancelled')) {
179
+ }
180
+ // Send the request. The `finally` releases the event bubbling on every outcome: a resumed
181
+ // session is long-lived, so leaking a listener per failed round would forward its events
182
+ // into stale parent responses.
183
+ try {
184
+ const chatRequest = {
185
+ text: `@${agentId} ${prompt}`,
186
+ };
187
+ let response;
188
+ try {
189
+ if (ctx.cancellationToken?.isCancellationRequested) {
182
190
  return 'Operation cancelled by user';
183
191
  }
184
- const errorMsg = `Failed to complete response from agent '${agentId}': ${completionError instanceof Error ? completionError.message : completionError}`;
185
- this.logger.error(errorMsg, completionError);
192
+ const chatService = this.getChatService();
193
+ response = await chatService.sendRequest(session.id, chatRequest);
194
+ if (ctx.cancellationToken) {
195
+ ctx.cancellationToken.onCancellationRequested(async () => {
196
+ if (response) {
197
+ (await response?.requestCompleted).cancel();
198
+ }
199
+ });
200
+ }
201
+ }
202
+ catch (sendError) {
203
+ const errorMsg = `Failed to send request to agent '${agentId}': ${sendError instanceof Error ? sendError.message : sendError}`;
204
+ this.logger.error(errorMsg, sendError);
205
+ return errorMsg;
206
+ }
207
+ if (response) {
208
+ // Store the invocation in the registry so the renderer can access it
209
+ if (ctx.toolCallId) {
210
+ this.pendingDelegations.set(ctx.toolCallId, {
211
+ prompt,
212
+ invocation: response
213
+ });
214
+ // Clean up when the delegated session is deleted
215
+ const chatService = this.getChatService();
216
+ const toolCallId = ctx.toolCallId;
217
+ const sessionEventListener = chatService.onSessionEvent(event => {
218
+ if (event.type === 'deleted' && event.sessionId === session.id) {
219
+ this.pendingDelegations.delete(toolCallId);
220
+ sessionEventListener.dispose();
221
+ }
222
+ });
223
+ }
224
+ try {
225
+ // Wait for completion to return the final result as tool output
226
+ const result = await response.responseCompleted;
227
+ const filteredContent = result.response.content.filter(c => !common_1.ThinkingChatResponseContent.is(c) && !common_1.ToolCallChatResponseContent.is(c));
228
+ const stringResult = filteredContent
229
+ .map(c => common_1.ChatResponseContent.hasAsString(c) ? c.asString() : undefined)
230
+ .filter((text) => text !== undefined && text !== '')
231
+ .join('\n\n');
232
+ // Return the raw text to the top-level Agent, as a tool result. The session id
233
+ // allows the caller to send follow-up requests into the same session.
234
+ const sessionIdSuffix = `[delegation sessionId: ${session.id}]`;
235
+ return stringResult ? `${stringResult}\n\n${sessionIdSuffix}` : sessionIdSuffix;
236
+ }
237
+ catch (completionError) {
238
+ if (completionError instanceof Error &&
239
+ completionError.message.includes('cancelled')) {
240
+ return 'Operation cancelled by user';
241
+ }
242
+ const errorMsg = `Failed to complete response from agent '${agentId}': ${completionError instanceof Error ? completionError.message : completionError}`;
243
+ this.logger.error(errorMsg, completionError);
244
+ return errorMsg;
245
+ }
246
+ }
247
+ else {
248
+ const errorMsg = `Delegation to agent '${agentId}' has failed: no response returned.`;
249
+ this.logger.error(errorMsg);
186
250
  return errorMsg;
187
251
  }
188
252
  }
189
- else {
190
- const errorMsg = `Delegation to agent '${agentId}' has failed: no response returned.`;
191
- this.logger.error(errorMsg);
192
- return errorMsg;
253
+ finally {
254
+ childModelDisposable?.dispose();
193
255
  }
194
256
  }
195
257
  catch (error) {
@@ -199,6 +261,23 @@ let AgentDelegationTool = class AgentDelegationTool {
199
261
  });
200
262
  }
201
263
  }
264
+ /**
265
+ * Makes the given task context the session's task context, replacing a previously set one.
266
+ * `addVariables` deduplicates on variable id *and* argument, so adding a different task context
267
+ * id would otherwise leave the session with both in its system prompt.
268
+ */
269
+ setTaskContext(context, taskContextId) {
270
+ const staleIndices = context.getVariables().reduce((indices, variable, index) => {
271
+ if (variable.variable.id === task_context_variable_1.TASK_CONTEXT_VARIABLE.id && variable.arg !== taskContextId) {
272
+ indices.push(index);
273
+ }
274
+ return indices;
275
+ }, []);
276
+ if (staleIndices.length > 0) {
277
+ context.deleteVariables(...staleIndices);
278
+ }
279
+ context.addVariables({ variable: task_context_variable_1.TASK_CONTEXT_VARIABLE, arg: taskContextId });
280
+ }
202
281
  /**
203
282
  * Sets up all event bubbling from a delegated child session to the parent session:
204
283
  * - Interaction forwarding: child interactionNeeded events are forwarded to the parent response
@@ -1 +1 @@
1
- {"version":3,"file":"agent-delegation-tool.js","sourceRoot":"","sources":["../../src/browser/agent-delegation-tool.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;;AAEhF,4DAAyE;AACzE,4CAAgH;AAChH,sCAAkD;AAClD,sCAgBmB;AACnB,mEAAgE;AAGzD,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAAzB;QAGgB,uBAAkB,GAAG,IAAI,GAAG,EAAiE,CAAC;IA4PrH,CAAC;;aA9PU,OAAE,GAAG,sCAA4B,AAA/B,CAAgC;IAazC,OAAO;QACH,OAAO;YACH,EAAE,EAAE,qBAAmB,CAAC,EAAE;YAC1B,IAAI,EAAE,qBAAmB,CAAC,EAAE;YAC5B,WAAW,EACP,8IAA8I;gBAC9I,uJAAuJ;gBACvJ,2JAA2J;gBAC3J,iCAAiC;gBACjC,+IAA+I;YACnJ,UAAU,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACR,OAAO,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,WAAW,EACP,iDAAiD;qBACxD;oBACD,MAAM,EAAE;wBACJ,IAAI,EAA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AAuB,CAAC;;gEAC+B;AAG5C;IADlB,IAAA,kBAAM,EAAC,2BAAkB,CAAC;;2DAC0B;AAGlC;IADlB,IAAA,kBAAM,EAAC,cAAO,CAAC;IAAE,IAAA,iBAAK,EAAC,6BAA6B,CAAC;;mDACnB;8BAZ1B,mBAAmB;IAD/B,IAAA,sBAAU,GAAE;GACA,mBAAmB,CA+P/B"}
1
+ {"version":3,"file":"agent-delegation-tool.js","sourceRoot":"","sources":["../../src/browser/agent-delegation-tool.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;;AAEhF,4DAAyE;AACzE,4CAAgH;AAChH,sCAAkD;AAClD,sCAmBmB;AACnB,mEAAgE;AAGzD,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAAzB;QAGgB,uBAAkB,GAAG,IAAI,GAAG,EAAiE,CAAC;IA2UrH,CAAC;;aA7UU,OAAE,GAAG,sCAA4B,AAA/B,CAAgC;IAazC,OAAO;QACH,OAAO;YACH,EAAE,EAAE,qBAAmB,CAAC,EAAE;YAC1B,IAAI,EAAE,qBAAmB,CAAC,EAAE;YAC5B,WAAW,EACP,8IAA8I;gBAC9I,yJAAyJ;gBACzJ,oJAAoJ;gBACpJ,6FAA6F;gBAC7F,qJAAqJ;gBACrJ,kIAAkI;gBAClI,2GAA2G;gBAC3G,+IAA+I;YACnJ,UAAU,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACR,OAAO,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,WAAW,EACP,iDAAiD;qBACxD;oBACD,MAAM,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,WAAW,EACP,+DAA+D;qBACtE;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AC,CAAC;YAC5D,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO;YACH,OAAO,EAAE,GAAG,EAAE;gBACV,eAAe,CAAC,OAAO,EAAE,CAAC;gBAC1B,mBAAmB,CAAC,OAAO,EAAE,CAAC;YAClC,CAAC;SACJ,CAAC;IACN,CAAC;;AA7UQ,kDAAmB;AAMT;IADlB,IAAA,kBAAM,EAAC,gCAAuB,CAAC;;gEAC+B;AAG5C;IADlB,IAAA,kBAAM,EAAC,2BAAkB,CAAC;;2DAC0B;AAGlC;IADlB,IAAA,kBAAM,EAAC,cAAO,CAAC;IAAE,IAAA,iBAAK,EAAC,6BAA6B,CAAC;;mDACnB;8BAZ1B,mBAAmB;IAD/B,IAAA,sBAAU,GAAE;GACA,mBAAmB,CA8U/B"}
@@ -26,18 +26,22 @@ const chat_agent_service_1 = require("../common/chat-agent-service");
26
26
  const agent_delegation_tool_1 = require("./agent-delegation-tool");
27
27
  const task_context_variable_1 = require("./task-context-variable");
28
28
  disableJSDOM();
29
- // --- Factory ---
30
- function makeAgentDelegationTool(chatAgentService, chatService) {
29
+ function makeStubLogger() {
30
+ return { error: sinon.stub(), warn: sinon.stub(), info: sinon.stub(), debug: sinon.stub() };
31
+ }
32
+ function makeAgentDelegationTool(chatAgentService, chatService, logger = makeStubLogger()) {
31
33
  const tool = new agent_delegation_tool_1.AgentDelegationTool();
32
34
  Object.defineProperty(tool, 'getChatAgentService', { value: () => chatAgentService });
33
35
  Object.defineProperty(tool, 'getChatService', { value: () => chatService });
36
+ Object.defineProperty(tool, 'logger', { value: logger });
34
37
  return tool;
35
38
  }
36
39
  // --- Helper factories ---
37
40
  function makeContextManager() {
38
41
  return {
39
42
  addVariables: sinon.stub(),
40
- getVariables: sinon.stub().returns([])
43
+ getVariables: sinon.stub().returns([]),
44
+ deleteVariables: sinon.stub()
41
45
  };
42
46
  }
43
47
  function makeChangeSet() {
@@ -78,6 +82,23 @@ function makeChatContext() {
78
82
  response: {}
79
83
  };
80
84
  }
85
+ /** A session previously delegated by the calling session (see {@link makeParentSession}). */
86
+ function makeExistingSession(contextManager = makeContextManager()) {
87
+ return {
88
+ id: 'existing-session-id',
89
+ pinnedAgent: { id: 'test-agent', name: 'Test Agent' },
90
+ rootSessionId: 'original-root-id',
91
+ parentSessionId: 'parent-session-id',
92
+ model: {
93
+ status: 'idle',
94
+ context: contextManager,
95
+ changeSet: makeChangeSet(),
96
+ onDidChange: sinon.stub().returns({ dispose: sinon.stub() }),
97
+ rootSessionId: 'original-root-id',
98
+ parentSessionId: 'parent-session-id'
99
+ }
100
+ };
101
+ }
81
102
  function makeChatService(newSession, responseContent) {
82
103
  const content = responseContent ?? [{ kind: 'text', content: 'agent response', asString: () => 'agent response' }];
83
104
  const responseCompleted = Promise.resolve({
@@ -152,7 +173,7 @@ describe('AgentDelegationTool', () => {
152
173
  const ctx = makeChatContext();
153
174
  const argString = JSON.stringify({ agentId: 'test-agent', prompt: 'do something' });
154
175
  const result = await tool.getTool().handler(argString, ctx);
155
- (0, chai_1.expect)(result).to.equal('final answer');
176
+ (0, chai_1.expect)(result).to.equal('final answer\n\n[delegation sessionId: new-session-id]');
156
177
  (0, chai_1.expect)(result).to.not.include('thinking');
157
178
  });
158
179
  it('excludes tool call content from the tool result', async () => {
@@ -165,9 +186,9 @@ describe('AgentDelegationTool', () => {
165
186
  const ctx = makeChatContext();
166
187
  const argString = JSON.stringify({ agentId: 'test-agent', prompt: 'do something' });
167
188
  const result = await tool.getTool().handler(argString, ctx);
168
- (0, chai_1.expect)(result).to.equal('final answer');
189
+ (0, chai_1.expect)(result).to.equal('final answer\n\n[delegation sessionId: new-session-id]');
169
190
  });
170
- it('returns empty string when all content is thinking', async () => {
191
+ it('returns only the session id marker when all content is thinking', async () => {
171
192
  const thinkingContent = new common_1.ThinkingChatResponseContentImpl('internal', 'sig');
172
193
  const newSession = makeNewSession();
173
194
  const agentService = makeChatAgentService();
@@ -176,7 +197,149 @@ describe('AgentDelegationTool', () => {
176
197
  const ctx = makeChatContext();
177
198
  const argString = JSON.stringify({ agentId: 'test-agent', prompt: 'do something' });
178
199
  const result = await tool.getTool().handler(argString, ctx);
179
- (0, chai_1.expect)(result).to.equal('');
200
+ (0, chai_1.expect)(result).to.equal('[delegation sessionId: new-session-id]');
201
+ });
202
+ });
203
+ describe('delegateToAgent() — delegation session id in result', () => {
204
+ it('appends the delegation session id to the tool result', async () => {
205
+ const newSession = makeNewSession();
206
+ const agentService = makeChatAgentService();
207
+ const chatService = makeChatService(newSession);
208
+ const tool = makeAgentDelegationTool(agentService, chatService);
209
+ const ctx = makeChatContext();
210
+ const argString = JSON.stringify({ agentId: 'test-agent', prompt: 'do something' });
211
+ const result = await tool.getTool().handler(argString, ctx);
212
+ (0, chai_1.expect)(result).to.equal('agent response\n\n[delegation sessionId: new-session-id]');
213
+ });
214
+ });
215
+ describe('delegateToAgent() — sessionId parameter (resume)', () => {
216
+ let contextManager;
217
+ let existingSession;
218
+ let chatService;
219
+ let tool;
220
+ let logger;
221
+ let ctx;
222
+ beforeEach(() => {
223
+ contextManager = makeContextManager();
224
+ existingSession = makeExistingSession(contextManager);
225
+ const newSession = makeNewSession();
226
+ const agentService = makeChatAgentService();
227
+ chatService = makeChatService(newSession);
228
+ chatService.getSession.withArgs('existing-session-id').returns(existingSession);
229
+ chatService.getOrRestoreSession.withArgs('existing-session-id').resolves(existingSession);
230
+ logger = makeStubLogger();
231
+ tool = makeAgentDelegationTool(agentService, chatService, logger);
232
+ ctx = makeChatContext();
233
+ });
234
+ it('sends the follow-up request into the existing session instead of creating a new one', async () => {
235
+ const argString = JSON.stringify({ agentId: 'test-agent', prompt: 'fix the findings', sessionId: 'existing-session-id' });
236
+ const result = await tool.getTool().handler(argString, ctx);
237
+ (0, chai_1.expect)(chatService.createSession.called).to.be.false;
238
+ const sendRequest = chatService.sendRequest;
239
+ (0, chai_1.expect)(sendRequest.calledOnce).to.be.true;
240
+ (0, chai_1.expect)(sendRequest.firstCall.args[0]).to.equal('existing-session-id');
241
+ (0, chai_1.expect)(result).to.equal('agent response\n\n[delegation sessionId: existing-session-id]');
242
+ });
243
+ it('re-establishes event bubbling from the resumed session to the parent', async () => {
244
+ const argString = JSON.stringify({ agentId: 'test-agent', prompt: 'fix the findings', sessionId: 'existing-session-id' });
245
+ await tool.getTool().handler(argString, ctx);
246
+ (0, chai_1.expect)(existingSession.model.onDidChange.calledOnce).to.be.true;
247
+ (0, chai_1.expect)(existingSession.model.changeSet.onDidChange.calledOnce).to.be.true;
248
+ });
249
+ it('does not modify rootSessionId or parentSessionId of the resumed session', async () => {
250
+ const argString = JSON.stringify({ agentId: 'test-agent', prompt: 'fix the findings', sessionId: 'existing-session-id' });
251
+ await tool.getTool().handler(argString, ctx);
252
+ (0, chai_1.expect)(existingSession.rootSessionId).to.equal('original-root-id');
253
+ (0, chai_1.expect)(existingSession.parentSessionId).to.equal('parent-session-id');
254
+ (0, chai_1.expect)(existingSession.model.rootSessionId).to.equal('original-root-id');
255
+ (0, chai_1.expect)(existingSession.model.parentSessionId).to.equal('parent-session-id');
256
+ });
257
+ it('adds the task context variable to the resumed session when taskContextId is provided', async () => {
258
+ const argString = JSON.stringify({
259
+ agentId: 'test-agent', prompt: 'fix the findings', sessionId: 'existing-session-id', taskContextId: 'follow-up-ctx-id'
260
+ });
261
+ await tool.getTool().handler(argString, ctx);
262
+ (0, chai_1.expect)(contextManager.addVariables.calledOnce).to.be.true;
263
+ const callArg = contextManager.addVariables.firstCall.args[0];
264
+ (0, chai_1.expect)(callArg.variable).to.equal(task_context_variable_1.TASK_CONTEXT_VARIABLE);
265
+ (0, chai_1.expect)(callArg.arg).to.equal('follow-up-ctx-id');
266
+ });
267
+ it('restores a delegation session that is persisted but no longer in memory', async () => {
268
+ // e.g. after a page reload: the orchestrator history still carries the session id, but only storage has the session
269
+ chatService.getSession.withArgs('existing-session-id').returns(undefined);
270
+ const argString = JSON.stringify({ agentId: 'test-agent', prompt: 'fix the findings', sessionId: 'existing-session-id' });
271
+ const result = await tool.getTool().handler(argString, ctx);
272
+ const sendRequest = chatService.sendRequest;
273
+ (0, chai_1.expect)(sendRequest.calledOnce).to.be.true;
274
+ (0, chai_1.expect)(sendRequest.firstCall.args[0]).to.equal('existing-session-id');
275
+ (0, chai_1.expect)(result).to.equal('agent response\n\n[delegation sessionId: existing-session-id]');
276
+ });
277
+ it('replaces a previous task context when a different taskContextId is provided', async () => {
278
+ contextManager.getVariables.returns([{ variable: task_context_variable_1.TASK_CONTEXT_VARIABLE, arg: 'stale-ctx-id' }]);
279
+ const argString = JSON.stringify({
280
+ agentId: 'test-agent', prompt: 'fix the findings', sessionId: 'existing-session-id', taskContextId: 'new-ctx-id'
281
+ });
282
+ await tool.getTool().handler(argString, ctx);
283
+ (0, chai_1.expect)(contextManager.deleteVariables.calledOnceWithExactly(0)).to.be.true;
284
+ const callArg = contextManager.addVariables.firstCall.args[0];
285
+ (0, chai_1.expect)(callArg.arg).to.equal('new-ctx-id');
286
+ });
287
+ it('keeps the existing task context when the same taskContextId is provided again', async () => {
288
+ contextManager.getVariables.returns([{ variable: task_context_variable_1.TASK_CONTEXT_VARIABLE, arg: 'same-ctx-id' }]);
289
+ const argString = JSON.stringify({
290
+ agentId: 'test-agent', prompt: 'fix the findings', sessionId: 'existing-session-id', taskContextId: 'same-ctx-id'
291
+ });
292
+ await tool.getTool().handler(argString, ctx);
293
+ (0, chai_1.expect)(contextManager.deleteVariables.called).to.be.false;
294
+ });
295
+ it('disposes the event bubbling when the delegated request fails', async () => {
296
+ chatService.sendRequest.rejects(new Error('provider unavailable'));
297
+ const argString = JSON.stringify({ agentId: 'test-agent', prompt: 'fix the findings', sessionId: 'existing-session-id' });
298
+ await tool.getTool().handler(argString, ctx);
299
+ (0, chai_1.expect)(existingSession.model.onDidChange.firstCall.returnValue.dispose.called).to.be.true;
300
+ (0, chai_1.expect)(existingSession.model.changeSet.onDidChange.firstCall.returnValue.dispose.called).to.be.true;
301
+ });
302
+ it('returns an error when the session was delegated by a different session', async () => {
303
+ existingSession.parentSessionId = 'someone-elses-session-id';
304
+ const argString = JSON.stringify({ agentId: 'test-agent', prompt: 'fix the findings', sessionId: 'existing-session-id' });
305
+ const result = await tool.getTool().handler(argString, ctx);
306
+ (0, chai_1.expect)(result).to.include('was not delegated by this session');
307
+ (0, chai_1.expect)(chatService.sendRequest.called).to.be.false;
308
+ });
309
+ it('returns an error when the session is not a delegated session at all', async () => {
310
+ // e.g. the id of a normal top-level user chat
311
+ existingSession.parentSessionId = undefined;
312
+ const argString = JSON.stringify({ agentId: 'test-agent', prompt: 'fix the findings', sessionId: 'existing-session-id' });
313
+ const result = await tool.getTool().handler(argString, ctx);
314
+ (0, chai_1.expect)(result).to.include('was not delegated by this session');
315
+ (0, chai_1.expect)(chatService.sendRequest.called).to.be.false;
316
+ });
317
+ it('returns an error when the sessionId is unknown', async () => {
318
+ const argString = JSON.stringify({ agentId: 'test-agent', prompt: 'fix the findings', sessionId: 'unknown-session-id' });
319
+ const result = await tool.getTool().handler(argString, ctx);
320
+ (0, chai_1.expect)(result).to.include('not found');
321
+ (0, chai_1.expect)(chatService.sendRequest.called).to.be.false;
322
+ (0, chai_1.expect)(chatService.createSession.called).to.be.false;
323
+ (0, chai_1.expect)(logger.warn.calledOnce).to.be.true;
324
+ (0, chai_1.expect)(logger.error.called).to.be.false;
325
+ });
326
+ it('returns an error when the resumed session is still processing a request', async () => {
327
+ existingSession.model.status = 'running';
328
+ const argString = JSON.stringify({ agentId: 'test-agent', prompt: 'fix the findings', sessionId: 'existing-session-id' });
329
+ const result = await tool.getTool().handler(argString, ctx);
330
+ (0, chai_1.expect)(result).to.include('still processing');
331
+ (0, chai_1.expect)(chatService.sendRequest.called).to.be.false;
332
+ (0, chai_1.expect)(logger.warn.calledOnce).to.be.true;
333
+ (0, chai_1.expect)(logger.error.called).to.be.false;
334
+ });
335
+ it('returns an error when agentId does not match the pinned agent of the session', async () => {
336
+ existingSession.pinnedAgent = { id: 'other-agent', name: 'Other Agent' };
337
+ const argString = JSON.stringify({ agentId: 'test-agent', prompt: 'fix the findings', sessionId: 'existing-session-id' });
338
+ const result = await tool.getTool().handler(argString, ctx);
339
+ (0, chai_1.expect)(result).to.include("belongs to agent 'other-agent'");
340
+ (0, chai_1.expect)(chatService.sendRequest.called).to.be.false;
341
+ (0, chai_1.expect)(logger.error.calledOnce).to.be.true;
342
+ (0, chai_1.expect)(logger.warn.called).to.be.false;
180
343
  });
181
344
  });
182
345
  describe('delegateToAgent() — session persistence', () => {