summaryrefslogtreecommitdiff
path: root/packages/cli/src/nonInteractiveCli.ts
diff options
context:
space:
mode:
authoranj-s <[email protected]>2025-07-11 07:55:03 -0700
committerGitHub <[email protected]>2025-07-11 14:55:03 +0000
commitc9e1e6d3bdfe1fa1582f278d6f1a606353313642 (patch)
treec6a78c450431d5fca390b1448d0f12e99da13ccc /packages/cli/src/nonInteractiveCli.ts
parent0151a9e1a3451221faf52e883b2c9d6a49eb1b5c (diff)
Add support for specifying maxSessionTurns via the settings configuration (#3507)
Diffstat (limited to 'packages/cli/src/nonInteractiveCli.ts')
-rw-r--r--packages/cli/src/nonInteractiveCli.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/packages/cli/src/nonInteractiveCli.ts b/packages/cli/src/nonInteractiveCli.ts
index b8b8ac3f..2db28eba 100644
--- a/packages/cli/src/nonInteractiveCli.ts
+++ b/packages/cli/src/nonInteractiveCli.ts
@@ -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(