mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 01:07:46 +00:00
remove editCorrector / compress logic in yolo
This commit is contained in:
@@ -77,6 +77,11 @@ export interface BugCommandSettings {
|
|||||||
|
|
||||||
export interface ChatCompressionSettings {
|
export interface ChatCompressionSettings {
|
||||||
contextPercentageThreshold?: number;
|
contextPercentageThreshold?: number;
|
||||||
|
/**
|
||||||
|
* When true, disables automatic chat history compression while in YOLO approval mode.
|
||||||
|
* Manual compression via commands remains available.
|
||||||
|
*/
|
||||||
|
disableInYolo?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SummarizeToolOutputSettings {
|
export interface SummarizeToolOutputSettings {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import {
|
|||||||
GeminiEventType,
|
GeminiEventType,
|
||||||
ChatCompressionInfo,
|
ChatCompressionInfo,
|
||||||
} from './turn.js';
|
} from './turn.js';
|
||||||
import { Config } from '../config/config.js';
|
import { ApprovalMode, Config } from '../config/config.js';
|
||||||
import { UserTierId } from '../code_assist/types.js';
|
import { UserTierId } from '../code_assist/types.js';
|
||||||
import {
|
import {
|
||||||
getCoreSystemPrompt,
|
getCoreSystemPrompt,
|
||||||
@@ -478,11 +478,19 @@ export class GeminiClient {
|
|||||||
// Track the original model from the first call to detect model switching
|
// Track the original model from the first call to detect model switching
|
||||||
const initialModel = originalModel || this.config.getModel();
|
const initialModel = originalModel || this.config.getModel();
|
||||||
|
|
||||||
|
const chatCompression = this.config.getChatCompression();
|
||||||
|
const disableAutoCompressionInYolo =
|
||||||
|
this.config.getApprovalMode() === ApprovalMode.YOLO &&
|
||||||
|
// Default to disabling auto-compression in YOLO unless explicitly set to false
|
||||||
|
(chatCompression?.disableInYolo ?? true);
|
||||||
|
|
||||||
|
if (!disableAutoCompressionInYolo) {
|
||||||
const compressed = await this.tryCompressChat(prompt_id);
|
const compressed = await this.tryCompressChat(prompt_id);
|
||||||
|
|
||||||
if (compressed) {
|
if (compressed) {
|
||||||
yield { type: GeminiEventType.ChatCompressed, value: compressed };
|
yield { type: GeminiEventType.ChatCompressed, value: compressed };
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check session token limit after compression using accurate token counting
|
// Check session token limit after compression using accurate token counting
|
||||||
const sessionTokenLimit = this.config.getSessionTokenLimit();
|
const sessionTokenLimit = this.config.getSessionTokenLimit();
|
||||||
|
|||||||
@@ -156,6 +156,8 @@ class EditToolInvocation implements ToolInvocation<EditToolParams, ToolResult> {
|
|||||||
params,
|
params,
|
||||||
this.config.getGeminiClient(),
|
this.config.getGeminiClient(),
|
||||||
abortSignal,
|
abortSignal,
|
||||||
|
// Disable LLM-based corrections in YOLO mode
|
||||||
|
this.config.getApprovalMode() !== ApprovalMode.YOLO,
|
||||||
);
|
);
|
||||||
finalOldString = correctedEdit.params.old_string;
|
finalOldString = correctedEdit.params.old_string;
|
||||||
finalNewString = correctedEdit.params.new_string;
|
finalNewString = correctedEdit.params.new_string;
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ export async function getCorrectedFileContent(
|
|||||||
},
|
},
|
||||||
config.getGeminiClient(),
|
config.getGeminiClient(),
|
||||||
abortSignal,
|
abortSignal,
|
||||||
|
// Disable LLM-based corrections in YOLO mode
|
||||||
|
config.getApprovalMode() !== ApprovalMode.YOLO,
|
||||||
);
|
);
|
||||||
correctedContent = correctedParams.new_string;
|
correctedContent = correctedParams.new_string;
|
||||||
} else {
|
} else {
|
||||||
@@ -124,6 +126,8 @@ export async function getCorrectedFileContent(
|
|||||||
proposedContent,
|
proposedContent,
|
||||||
config.getGeminiClient(),
|
config.getGeminiClient(),
|
||||||
abortSignal,
|
abortSignal,
|
||||||
|
// Disable LLM-based corrections in YOLO mode
|
||||||
|
config.getApprovalMode() !== ApprovalMode.YOLO,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return { originalContent, correctedContent, fileExists };
|
return { originalContent, correctedContent, fileExists };
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ export async function ensureCorrectEdit(
|
|||||||
originalParams: EditToolParams, // This is the EditToolParams from edit.ts, without \'corrected\'
|
originalParams: EditToolParams, // This is the EditToolParams from edit.ts, without \'corrected\'
|
||||||
client: GeminiClient,
|
client: GeminiClient,
|
||||||
abortSignal: AbortSignal,
|
abortSignal: AbortSignal,
|
||||||
|
llmCorrectionsEnabled: boolean = true,
|
||||||
): Promise<CorrectedEditResult> {
|
): Promise<CorrectedEditResult> {
|
||||||
const cacheKey = `${currentContent}---${originalParams.old_string}---${originalParams.new_string}`;
|
const cacheKey = `${currentContent}---${originalParams.old_string}---${originalParams.new_string}`;
|
||||||
const cachedResult = editCorrectionCache.get(cacheKey);
|
const cachedResult = editCorrectionCache.get(cacheKey);
|
||||||
@@ -178,7 +179,7 @@ export async function ensureCorrectEdit(
|
|||||||
let occurrences = countOccurrences(currentContent, finalOldString);
|
let occurrences = countOccurrences(currentContent, finalOldString);
|
||||||
|
|
||||||
if (occurrences === expectedReplacements) {
|
if (occurrences === expectedReplacements) {
|
||||||
if (newStringPotentiallyEscaped) {
|
if (newStringPotentiallyEscaped && llmCorrectionsEnabled) {
|
||||||
finalNewString = await correctNewStringEscaping(
|
finalNewString = await correctNewStringEscaping(
|
||||||
client,
|
client,
|
||||||
finalOldString,
|
finalOldString,
|
||||||
@@ -225,7 +226,7 @@ export async function ensureCorrectEdit(
|
|||||||
|
|
||||||
if (occurrences === expectedReplacements) {
|
if (occurrences === expectedReplacements) {
|
||||||
finalOldString = unescapedOldStringAttempt;
|
finalOldString = unescapedOldStringAttempt;
|
||||||
if (newStringPotentiallyEscaped) {
|
if (newStringPotentiallyEscaped && llmCorrectionsEnabled) {
|
||||||
finalNewString = await correctNewString(
|
finalNewString = await correctNewString(
|
||||||
client,
|
client,
|
||||||
originalParams.old_string, // original old
|
originalParams.old_string, // original old
|
||||||
@@ -263,6 +264,7 @@ export async function ensureCorrectEdit(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (llmCorrectionsEnabled) {
|
||||||
const llmCorrectedOldString = await correctOldStringMismatch(
|
const llmCorrectedOldString = await correctOldStringMismatch(
|
||||||
client,
|
client,
|
||||||
currentContent,
|
currentContent,
|
||||||
@@ -299,6 +301,15 @@ export async function ensureCorrectEdit(
|
|||||||
editCorrectionCache.set(cacheKey, result);
|
editCorrectionCache.set(cacheKey, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// LLM corrections disabled -> return as-is to surface mismatch upstream
|
||||||
|
const result: CorrectedEditResult = {
|
||||||
|
params: { ...originalParams },
|
||||||
|
occurrences: 0,
|
||||||
|
};
|
||||||
|
editCorrectionCache.set(cacheKey, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Unescaping old_string resulted in > 1 occurrence
|
// Unescaping old_string resulted in > 1 occurrence
|
||||||
const result: CorrectedEditResult = {
|
const result: CorrectedEditResult = {
|
||||||
@@ -336,6 +347,7 @@ export async function ensureCorrectFileContent(
|
|||||||
content: string,
|
content: string,
|
||||||
client: GeminiClient,
|
client: GeminiClient,
|
||||||
abortSignal: AbortSignal,
|
abortSignal: AbortSignal,
|
||||||
|
llmCorrectionsEnabled: boolean = true,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const cachedResult = fileContentCorrectionCache.get(content);
|
const cachedResult = fileContentCorrectionCache.get(content);
|
||||||
if (cachedResult) {
|
if (cachedResult) {
|
||||||
@@ -349,11 +361,9 @@ export async function ensureCorrectFileContent(
|
|||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
const correctedContent = await correctStringEscaping(
|
const correctedContent = llmCorrectionsEnabled
|
||||||
content,
|
? await correctStringEscaping(content, client, abortSignal)
|
||||||
client,
|
: content;
|
||||||
abortSignal,
|
|
||||||
);
|
|
||||||
fileContentCorrectionCache.set(content, correctedContent);
|
fileContentCorrectionCache.set(content, correctedContent);
|
||||||
return correctedContent;
|
return correctedContent;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user