Add support for specifying maxSessionTurns via the settings configuration (#3507)

This commit is contained in:
anj-s
2025-07-11 07:55:03 -07:00
committed by GitHub
parent 0151a9e1a3
commit c9e1e6d3bd
10 changed files with 231 additions and 15 deletions

View File

@@ -63,9 +63,19 @@ export async function runNonInteractive(
const chat = await geminiClient.getChat();
const abortController = new AbortController();
let currentMessages: Content[] = [{ role: 'user', parts: [{ text: input }] }];
let turnCount = 0;
try {
while (true) {
turnCount++;
if (
config.getMaxSessionTurns() > 0 &&
turnCount > config.getMaxSessionTurns()
) {
console.error(
'\n Reached max session turns for this session. Increase the number of turns by specifying maxSessionTurns in settings.json.',
);
return;
}
const functionCalls: FunctionCall[] = [];
const responseStream = await chat.sendMessageStream(