Skip to content

Commit da76b3a

Browse files
gundermancProthamD
authored andcommitted
Fix issue where subagent thoughts are appended. (google-gemini#22975)
1 parent cd1ef68 commit da76b3a

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

packages/core/src/agents/local-invocation.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ describe('LocalSubagentInvocation', () => {
230230
expect(display.terminateReason).toBe(AgentTerminateMode.TIMEOUT);
231231
});
232232

233-
it('should stream THOUGHT_CHUNK activities from the executor', async () => {
233+
it('should stream THOUGHT_CHUNK activities from the executor, replacing the last running thought', async () => {
234234
mockExecutorInstance.run.mockImplementation(async () => {
235235
const onActivity = MockLocalAgentExecutor.create.mock.calls[0][2];
236236

@@ -245,7 +245,7 @@ describe('LocalSubagentInvocation', () => {
245245
isSubagentActivityEvent: true,
246246
agentName: 'MockAgent',
247247
type: 'THOUGHT_CHUNK',
248-
data: { text: ' Still thinking.' },
248+
data: { text: 'Thinking about next steps.' },
249249
} as SubagentActivityEvent);
250250
}
251251
return { result: 'Done', terminate_reason: AgentTerminateMode.GOAL };
@@ -258,7 +258,13 @@ describe('LocalSubagentInvocation', () => {
258258
expect(lastCall.recentActivity).toContainEqual(
259259
expect.objectContaining({
260260
type: 'thought',
261-
content: 'Analyzing... Still thinking.',
261+
content: 'Thinking about next steps.',
262+
}),
263+
);
264+
expect(lastCall.recentActivity).not.toContainEqual(
265+
expect.objectContaining({
266+
type: 'thought',
267+
content: 'Analyzing...',
262268
}),
263269
);
264270
});

packages/core/src/agents/local-invocation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export class LocalSubagentInvocation extends BaseToolInvocation<
120120
lastItem.type === 'thought' &&
121121
lastItem.status === 'running'
122122
) {
123-
lastItem.content += text;
123+
lastItem.content = text;
124124
} else {
125125
recentActivity.push({
126126
id: randomUUID(),

0 commit comments

Comments
 (0)