remove read_folder context before user input

This commit is contained in:
koalazf.99
2025-09-16 16:27:01 +08:00
parent 740768dc1b
commit 92af02c494
5 changed files with 43 additions and 16 deletions

View File

@@ -603,6 +603,7 @@ export async function loadCliConfig(
interactive,
trustedFolder,
shouldUseNodePtyShell: settings.shouldUseNodePtyShell,
skipStartupContext: settings.skipStartupContext,
skipNextSpeakerCheck: settings.skipNextSpeakerCheck,
});
}

View File

@@ -595,12 +595,22 @@ export const SETTINGS_SCHEMA = {
description: 'The API key for the Tavily API.',
showInDialog: false,
},
skipStartupContext: {
type: 'boolean',
label: 'Skip Startup Context',
category: 'General',
requiresRestart: false,
default: true,
description:
'Do not prepend environment/folder structure context or the initial acknowledgment message.',
showInDialog: true,
},
skipNextSpeakerCheck: {
type: 'boolean',
label: 'Skip Next Speaker Check',
category: 'General',
requiresRestart: false,
default: false,
default: true,
description: 'Skip the next speaker check.',
showInDialog: true,
},

View File

@@ -232,6 +232,7 @@ export interface ConfigParameters {
interactive?: boolean;
trustedFolder?: boolean;
shouldUseNodePtyShell?: boolean;
skipStartupContext?: boolean;
skipNextSpeakerCheck?: boolean;
}
@@ -317,6 +318,7 @@ export class Config {
private readonly interactive: boolean;
private readonly trustedFolder: boolean | undefined;
private readonly shouldUseNodePtyShell: boolean;
private readonly skipStartupContext: boolean;
private readonly skipNextSpeakerCheck: boolean;
private initialized: boolean = false;
@@ -398,7 +400,8 @@ export class Config {
this.interactive = params.interactive ?? false;
this.trustedFolder = params.trustedFolder;
this.shouldUseNodePtyShell = params.shouldUseNodePtyShell ?? false;
this.skipNextSpeakerCheck = params.skipNextSpeakerCheck ?? false;
this.skipStartupContext = params.skipStartupContext ?? true;
this.skipNextSpeakerCheck = params.skipNextSpeakerCheck ?? true;
// Web search
this.tavilyApiKey = params.tavilyApiKey;
@@ -857,6 +860,10 @@ export class Config {
return this.shouldUseNodePtyShell;
}
getSkipStartupContext(): boolean {
return this.skipStartupContext;
}
getSkipNextSpeakerCheck(): boolean {
return this.skipNextSpeakerCheck;
}

View File

@@ -228,19 +228,24 @@ export class GeminiClient {
async startChat(extraHistory?: Content[]): Promise<GeminiChat> {
this.forceFullIdeContext = true;
const envParts = await getEnvironmentContext(this.config);
const envParts = this.config.getSkipStartupContext()
? []
: await getEnvironmentContext(this.config);
const toolRegistry = this.config.getToolRegistry();
const toolDeclarations = toolRegistry.getFunctionDeclarations();
const tools: Tool[] = [{ functionDeclarations: toolDeclarations }];
const history: Content[] = [
{
role: 'user',
parts: envParts,
},
{
role: 'model',
parts: [{ text: 'Got it. Thanks for the context!' }],
},
...(
envParts.length
? [
{ role: 'user', parts: envParts },
{
role: 'model',
parts: [{ text: 'Got it. Thanks for the context!' }],
},
]
: []
),
...(extraHistory ?? []),
];
try {

View File

@@ -781,11 +781,15 @@ export class SubAgentScope {
);
}
const envParts = await getEnvironmentContext(this.runtimeContext);
const envHistory: Content[] = [
{ role: 'user', parts: envParts },
{ role: 'model', parts: [{ text: 'Got it. Thanks for the context!' }] },
];
const envParts = this.runtimeContext.getSkipStartupContext()
? []
: await getEnvironmentContext(this.runtimeContext);
const envHistory: Content[] = envParts.length
? [
{ role: 'user', parts: envParts },
{ role: 'model', parts: [{ text: 'Got it. Thanks for the context!' }] },
]
: [];
const start_history = [
...envHistory,