Session-Level Conversation History Management (#1113)

This commit is contained in:
tanzhenxin
2025-12-03 18:04:48 +08:00
committed by GitHub
parent a7abd8d09f
commit 0a75d85ac9
114 changed files with 9257 additions and 4039 deletions

View File

@@ -205,9 +205,7 @@ describe('ExitPlanModeTool', () => {
};
const invocation = tool.build(params);
expect(invocation.getDescription()).toBe(
'Present implementation plan for user approval',
);
expect(invocation.getDescription()).toBe('Plan:');
});
it('should return empty tool locations', () => {

View File

@@ -60,7 +60,7 @@ class ExitPlanModeToolInvocation extends BaseToolInvocation<
}
getDescription(): string {
return 'Present implementation plan for user approval';
return 'Plan:';
}
override async shouldConfirmExecute(

View File

@@ -29,10 +29,6 @@ vi.mock(import('node:fs/promises'), async (importOriginal) => {
};
});
vi.mock('fs', () => ({
mkdirSync: vi.fn(),
}));
vi.mock('os');
const MEMORY_SECTION_HEADER = '## Qwen Added Memories';

View File

@@ -144,30 +144,6 @@ describe('ReadFileTool', () => {
).toBe(path.join('sub', 'dir', 'file.txt'));
});
it('should return shortened path when file path is deep', () => {
const deepPath = path.join(
tempRootDir,
'very',
'deep',
'directory',
'structure',
'that',
'exceeds',
'the',
'normal',
'limit',
'file.txt',
);
const params: ReadFileToolParams = { absolute_path: deepPath };
const invocation = tool.build(params);
expect(typeof invocation).not.toBe('string');
const desc = (
invocation as ToolInvocation<ReadFileToolParams, ToolResult>
).getDescription();
expect(desc).toContain('...');
expect(desc).toContain('file.txt');
});
it('should handle non-normalized file paths correctly', () => {
const subDir = path.join(tempRootDir, 'sub', 'dir');
const params: ReadFileToolParams = {

View File

@@ -57,7 +57,18 @@ class ReadFileToolInvocation extends BaseToolInvocation<
this.params.absolute_path,
this.config.getTargetDir(),
);
return shortenPath(relativePath);
const shortPath = shortenPath(relativePath);
const { offset, limit } = this.params;
if (offset !== undefined && limit !== undefined) {
return `${shortPath} (lines ${offset + 1}-${offset + limit})`;
} else if (offset !== undefined) {
return `${shortPath} (from line ${offset + 1})`;
} else if (limit !== undefined) {
return `${shortPath} (first ${limit} lines)`;
}
return shortPath;
}
override toolLocations(): ToolLocation[] {

View File

@@ -104,7 +104,6 @@ const baseConfigParams: ConfigParameters = {
userMemory: '',
geminiMdFileCount: 0,
approvalMode: ApprovalMode.DEFAULT,
sessionId: 'test-session-id',
};
describe('ToolRegistry', () => {