@@ -225,23 +225,37 @@ export class GeminiClient {
225225 async startChat ( extraHistory ?: Content [ ] ) : Promise < GeminiChat > {
226226 this . forceFullIdeContext = true ;
227227 this . hasFailedCompressionAttempt = false ;
228- const envParts = await getEnvironmentContext ( this . config ) ;
229228
230229 const toolRegistry = this . config . getToolRegistry ( ) ;
231230 const toolDeclarations = toolRegistry . getFunctionDeclarations ( ) ;
232231 const tools : Tool [ ] = [ { functionDeclarations : toolDeclarations } ] ;
233232
233+ // 1. Get the environment context parts as an array
234+ const envParts = await getEnvironmentContext ( this . config ) ;
235+
236+ // 2. Convert the array of parts into a single string
237+ const envContextString = envParts
238+ . map ( ( part ) => part . text || '' )
239+ . join ( '\n\n' ) ;
240+
241+ // 3. Combine the dynamic context with the static handshake instruction
242+ const allSetupText = `
243+ ${ envContextString }
244+
245+ Reminder: Do not return an empty response when a tool call is required.
246+
247+ My setup is complete. I will provide my first command in the next turn.
248+ ` . trim ( ) ;
249+
250+ // 4. Create the history with a single, comprehensive user turn
234251 const history : Content [ ] = [
235252 {
236253 role : 'user' ,
237- parts : envParts ,
238- } ,
239- {
240- role : 'model' ,
241- parts : [ { text : 'Got it. Thanks for the context!' } ] ,
254+ parts : [ { text : allSetupText } ] ,
242255 } ,
243256 ...( extraHistory ?? [ ] ) ,
244257 ] ;
258+
245259 try {
246260 const userMemory = this . config . getUserMemory ( ) ;
247261 const systemInstruction = getCoreSystemPrompt ( this . config , userMemory ) ;
0 commit comments