mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-22 02:54:31 -07:00
robustness(core): static checks to validate history is immutable (#21228)
This commit is contained in:
@@ -130,7 +130,7 @@ export function modelStringToModelConfigAlias(model: string): string {
|
||||
* contain massive tool outputs (like large grep results or logs).
|
||||
*/
|
||||
async function truncateHistoryToBudget(
|
||||
history: Content[],
|
||||
history: readonly Content[],
|
||||
config: Config,
|
||||
): Promise<Content[]> {
|
||||
let functionResponseTokenCounter = 0;
|
||||
|
||||
@@ -664,7 +664,7 @@ export class ChatRecordingService {
|
||||
* Updates the conversation history based on the provided API Content array.
|
||||
* This is used to persist changes made to the history (like masking) back to disk.
|
||||
*/
|
||||
updateMessagesFromHistory(history: Content[]): void {
|
||||
updateMessagesFromHistory(history: readonly Content[]): void {
|
||||
if (!this.conversationFile) return;
|
||||
|
||||
try {
|
||||
|
||||
@@ -43,7 +43,7 @@ const EXEMPT_TOOLS = new Set([
|
||||
]);
|
||||
|
||||
export interface MaskingResult {
|
||||
newHistory: Content[];
|
||||
newHistory: readonly Content[];
|
||||
maskedCount: number;
|
||||
tokensSaved: number;
|
||||
}
|
||||
@@ -67,7 +67,10 @@ export interface MaskingResult {
|
||||
* are preserved until they collectively reach the threshold.
|
||||
*/
|
||||
export class ToolOutputMaskingService {
|
||||
async mask(history: Content[], config: Config): Promise<MaskingResult> {
|
||||
async mask(
|
||||
history: readonly Content[],
|
||||
config: Config,
|
||||
): Promise<MaskingResult> {
|
||||
const maskingConfig = await config.getToolOutputMaskingConfig();
|
||||
if (!maskingConfig.enabled || history.length === 0) {
|
||||
return { newHistory: history, maskedCount: 0, tokensSaved: 0 };
|
||||
|
||||
Reference in New Issue
Block a user