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, interactive,
trustedFolder, trustedFolder,
shouldUseNodePtyShell: settings.shouldUseNodePtyShell, shouldUseNodePtyShell: settings.shouldUseNodePtyShell,
skipStartupContext: settings.skipStartupContext,
skipNextSpeakerCheck: settings.skipNextSpeakerCheck, skipNextSpeakerCheck: settings.skipNextSpeakerCheck,
}); });
} }

View File

@@ -595,12 +595,22 @@ export const SETTINGS_SCHEMA = {
description: 'The API key for the Tavily API.', description: 'The API key for the Tavily API.',
showInDialog: false, 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: { skipNextSpeakerCheck: {
type: 'boolean', type: 'boolean',
label: 'Skip Next Speaker Check', label: 'Skip Next Speaker Check',
category: 'General', category: 'General',
requiresRestart: false, requiresRestart: false,
default: false, default: true,
description: 'Skip the next speaker check.', description: 'Skip the next speaker check.',
showInDialog: true, showInDialog: true,
}, },

View File

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

View File

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

View File

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