diff --git a/packages/core/src/core/geminiChat.ts b/packages/core/src/core/geminiChat.ts index b04318b488..4dc586e156 100644 --- a/packages/core/src/core/geminiChat.ts +++ b/packages/core/src/core/geminiChat.ts @@ -1007,6 +1007,8 @@ export class GeminiChat { status: call.status, timestamp: new Date().toISOString(), resultDisplay, + description: + 'invocation' in call ? call.invocation?.getDescription() : undefined, }; }); diff --git a/packages/core/src/services/chatRecordingService.test.ts b/packages/core/src/services/chatRecordingService.test.ts index 2b8e8f1977..4033f89fd9 100644 --- a/packages/core/src/services/chatRecordingService.test.ts +++ b/packages/core/src/services/chatRecordingService.test.ts @@ -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', diff --git a/packages/core/src/services/chatRecordingService.ts b/packages/core/src/services/chatRecordingService.ts index 8aba60b0e0..021d9845d8 100644 --- a/packages/core/src/services/chatRecordingService.ts +++ b/packages/core/src/services/chatRecordingService.ts @@ -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, }; });