fix(core): preserve dynamic tool descriptions on session resume (#18835)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Sehoon Shon
2026-03-11 15:38:54 -04:00
committed by GitHub
parent b87718d1ff
commit b7578eba7d
3 changed files with 34 additions and 1 deletions

View File

@@ -1007,6 +1007,8 @@ export class GeminiChat {
status: call.status,
timestamp: new Date().toISOString(),
resultDisplay,
description:
'invocation' in call ? call.invocation?.getDescription() : undefined,
};
});

View File

@@ -370,6 +370,36 @@ describe('ChatRecordingService', () => {
expect(geminiMsg.toolCalls![0].name).toBe('testTool');
});
it('should preserve dynamic description and NOT overwrite with generic one', () => {
chatRecordingService.recordMessage({
type: 'gemini',
content: '',
model: 'gemini-pro',
});
const dynamicDescription = 'DYNAMIC DESCRIPTION (e.g. Read file foo.txt)';
const toolCall: ToolCallRecord = {
id: 'tool-1',
name: 'testTool',
args: {},
status: CoreToolCallStatus.Success,
timestamp: new Date().toISOString(),
description: dynamicDescription,
};
chatRecordingService.recordToolCalls('gemini-pro', [toolCall]);
const sessionFile = chatRecordingService.getConversationFilePath()!;
const conversation = JSON.parse(
fs.readFileSync(sessionFile, 'utf8'),
) as ConversationRecord;
const geminiMsg = conversation.messages[0] as MessageRecord & {
type: 'gemini';
};
expect(geminiMsg.toolCalls![0].description).toBe(dynamicDescription);
});
it('should create a new message if the last message is not from gemini', () => {
chatRecordingService.recordMessage({
type: 'user',

View File

@@ -347,7 +347,8 @@ export class ChatRecordingService {
return {
...toolCall,
displayName: toolInstance?.displayName || toolCall.name,
description: toolInstance?.description || '',
description:
toolCall.description?.trim() || toolInstance?.description || '',
renderOutputAsMarkdown: toolInstance?.isOutputMarkdown || false,
};
});