mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 13:22:35 -07:00
fix(core): Minor fixes for generalist profile. (#26357)
This commit is contained in:
@@ -78,6 +78,7 @@ export const generalistProfile: ContextProfile = {
|
||||
budget: {
|
||||
retainedTokens: 65000,
|
||||
maxTokens: 150000,
|
||||
coalescingThresholdTokens: 5000,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -117,14 +118,14 @@ export const generalistProfile: ContextProfile = {
|
||||
'NodeDistillation',
|
||||
env,
|
||||
resolveProcessorOptions(config, 'NodeDistillation', {
|
||||
nodeThresholdTokens: 1000,
|
||||
nodeThresholdTokens: 3000,
|
||||
}),
|
||||
),
|
||||
createNodeTruncationProcessor(
|
||||
'NodeTruncation',
|
||||
env,
|
||||
resolveProcessorOptions(config, 'NodeTruncation', {
|
||||
maxTokensPerNode: 1200,
|
||||
maxTokensPerNode: 4000,
|
||||
}),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -42,6 +42,11 @@ export function getContextManagementConfigSchema(
|
||||
description:
|
||||
'The absolute maximum token count allowed before synchronous truncation kicks in.',
|
||||
},
|
||||
coalescingThresholdTokens: {
|
||||
type: 'number',
|
||||
description:
|
||||
'Only trigger background consolidation (snapshots) when at least this many tokens have aged out. Prevents "turn-by-turn" utility model churn.',
|
||||
},
|
||||
},
|
||||
},
|
||||
processorOptions: {
|
||||
|
||||
@@ -29,6 +29,11 @@ export interface AsyncPipelineDef {
|
||||
export interface ContextBudget {
|
||||
retainedTokens: number;
|
||||
maxTokens: number;
|
||||
/**
|
||||
* Only trigger background consolidation (snapshots) when at least this many
|
||||
* tokens have aged out. Prevents "turn-by-turn" utility model churn.
|
||||
*/
|
||||
coalescingThresholdTokens?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -141,15 +141,23 @@ export class ContextManager {
|
||||
}
|
||||
|
||||
if (agedOutNodes.size > 0) {
|
||||
this.env.tokenCalculator.garbageCollectCache(
|
||||
new Set(this.buffer.nodes.map((n) => n.id)),
|
||||
);
|
||||
this.eventBus.emitConsolidationNeeded({
|
||||
nodes: this.buffer.nodes,
|
||||
targetDeficit:
|
||||
currentTokens - this.sidecar.config.budget.retainedTokens,
|
||||
targetNodeIds: agedOutNodes,
|
||||
});
|
||||
const targetDeficit =
|
||||
currentTokens - this.sidecar.config.budget.retainedTokens;
|
||||
|
||||
// Respect coalescing threshold for background work
|
||||
const threshold =
|
||||
this.sidecar.config.budget.coalescingThresholdTokens || 0;
|
||||
|
||||
if (targetDeficit >= threshold) {
|
||||
this.env.tokenCalculator.garbageCollectCache(
|
||||
new Set(this.buffer.nodes.map((n) => n.id)),
|
||||
);
|
||||
this.eventBus.emitConsolidationNeeded({
|
||||
nodes: this.buffer.nodes,
|
||||
targetDeficit,
|
||||
targetNodeIds: agedOutNodes,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ export class SnapshotGenerator {
|
||||
const systemPrompt =
|
||||
systemInstruction ??
|
||||
`You are an expert Context Memory Manager. You will be provided with a raw transcript of older conversation turns between a user and an AI assistant.
|
||||
Your task is to synthesize these turns into a single, dense, factual snapshot that preserves all critical context, preferences, active tasks, and factual knowledge, but discards conversational filler, pleasantries, and redundant back-and-forth iterations.
|
||||
Your task is to synthesize these turns into a single, dense, factual snapshot that preserves all critical context, preferences, active tasks, and factual knowledge.
|
||||
|
||||
Output ONLY the raw factual snapshot, formatted compactly. Do not include markdown wrappers, prefixes like "Here is the snapshot", or conversational elements.`;
|
||||
Discard conversational filler, pleasantries, and redundant back-and-forth iterations. Output ONLY the raw factual snapshot, formatted compactly. Do not include markdown wrappers, prefixes like "Here is the snapshot", or conversational elements.`;
|
||||
|
||||
let userPromptText = 'TRANSCRIPT TO SNAPSHOT:\n\n';
|
||||
for (const node of nodes) {
|
||||
|
||||
@@ -289,6 +289,7 @@ describe('Gemini Client (client.ts)', () => {
|
||||
resetTurn: vi.fn(),
|
||||
|
||||
isAutoDistillationEnabled: vi.fn().mockReturnValue(false),
|
||||
isContextManagementEnabled: vi.fn().mockReturnValue(false),
|
||||
getContextManagementConfig: vi.fn().mockReturnValue({ enabled: false }),
|
||||
getModelAvailabilityService: vi
|
||||
.fn()
|
||||
|
||||
@@ -827,7 +827,10 @@ export class GeminiChat {
|
||||
const history = curated
|
||||
? extractCuratedHistory([...this.agentHistory.get()])
|
||||
: this.agentHistory.get();
|
||||
return [...history];
|
||||
|
||||
return this.context.config.isContextManagementEnabled()
|
||||
? scrubHistory([...history])
|
||||
: [...history];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user