mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 12:54:07 -07:00
fix(core): deduplicate project memory when JIT context is enabled (#22234)
This commit is contained in:
@@ -165,6 +165,29 @@ describe('getEnvironmentContext', () => {
|
|||||||
expect(getFolderStructure).not.toHaveBeenCalled();
|
expect(getFolderStructure).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should exclude environment memory when JIT context is enabled', async () => {
|
||||||
|
(mockConfig as Record<string, unknown>)['isJitContextEnabled'] = vi
|
||||||
|
.fn()
|
||||||
|
.mockReturnValue(true);
|
||||||
|
|
||||||
|
const parts = await getEnvironmentContext(mockConfig as Config);
|
||||||
|
|
||||||
|
const context = parts[0].text;
|
||||||
|
expect(context).not.toContain('Mock Environment Memory');
|
||||||
|
expect(mockConfig.getEnvironmentMemory).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should include environment memory when JIT context is disabled', async () => {
|
||||||
|
(mockConfig as Record<string, unknown>)['isJitContextEnabled'] = vi
|
||||||
|
.fn()
|
||||||
|
.mockReturnValue(false);
|
||||||
|
|
||||||
|
const parts = await getEnvironmentContext(mockConfig as Config);
|
||||||
|
|
||||||
|
const context = parts[0].text;
|
||||||
|
expect(context).toContain('Mock Environment Memory');
|
||||||
|
});
|
||||||
|
|
||||||
it('should handle read_many_files returning no content', async () => {
|
it('should handle read_many_files returning no content', async () => {
|
||||||
const mockReadManyFilesTool = {
|
const mockReadManyFilesTool = {
|
||||||
build: vi.fn().mockReturnValue({
|
build: vi.fn().mockReturnValue({
|
||||||
|
|||||||
@@ -57,7 +57,12 @@ export async function getEnvironmentContext(config: Config): Promise<Part[]> {
|
|||||||
? await getDirectoryContextString(config)
|
? await getDirectoryContextString(config)
|
||||||
: '';
|
: '';
|
||||||
const tempDir = config.storage.getProjectTempDir();
|
const tempDir = config.storage.getProjectTempDir();
|
||||||
const environmentMemory = config.getEnvironmentMemory();
|
// When JIT context is enabled, project memory is already included in the
|
||||||
|
// system instruction via renderUserMemory(). Skip it here to avoid sending
|
||||||
|
// the same GEMINI.md content twice.
|
||||||
|
const environmentMemory = config.isJitContextEnabled?.()
|
||||||
|
? ''
|
||||||
|
: config.getEnvironmentMemory();
|
||||||
|
|
||||||
const context = `
|
const context = `
|
||||||
<session_context>
|
<session_context>
|
||||||
|
|||||||
Reference in New Issue
Block a user