mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-30 06:54:15 -07:00
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:
@@ -1007,6 +1007,8 @@ export class GeminiChat {
|
|||||||
status: call.status,
|
status: call.status,
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
resultDisplay,
|
resultDisplay,
|
||||||
|
description:
|
||||||
|
'invocation' in call ? call.invocation?.getDescription() : undefined,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -370,6 +370,36 @@ describe('ChatRecordingService', () => {
|
|||||||
expect(geminiMsg.toolCalls![0].name).toBe('testTool');
|
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', () => {
|
it('should create a new message if the last message is not from gemini', () => {
|
||||||
chatRecordingService.recordMessage({
|
chatRecordingService.recordMessage({
|
||||||
type: 'user',
|
type: 'user',
|
||||||
|
|||||||
@@ -347,7 +347,8 @@ export class ChatRecordingService {
|
|||||||
return {
|
return {
|
||||||
...toolCall,
|
...toolCall,
|
||||||
displayName: toolInstance?.displayName || toolCall.name,
|
displayName: toolInstance?.displayName || toolCall.name,
|
||||||
description: toolInstance?.description || '',
|
description:
|
||||||
|
toolCall.description?.trim() || toolInstance?.description || '',
|
||||||
renderOutputAsMarkdown: toolInstance?.isOutputMarkdown || false,
|
renderOutputAsMarkdown: toolInstance?.isOutputMarkdown || false,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user