From c9e1e6d3bdfe1fa1582f278d6f1a606353313642 Mon Sep 17 00:00:00 2001 From: anj-s <32556631+anj-s@users.noreply.github.com> Date: Fri, 11 Jul 2025 07:55:03 -0700 Subject: Add support for specifying maxSessionTurns via the settings configuration (#3507) --- packages/cli/src/ui/hooks/useGeminiStream.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'packages/cli/src/ui/hooks') diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts index b82b0cb2..a9326528 100644 --- a/packages/cli/src/ui/hooks/useGeminiStream.ts +++ b/packages/cli/src/ui/hooks/useGeminiStream.ts @@ -431,6 +431,20 @@ export const useGeminiStream = ( [addItem, config], ); + const handleMaxSessionTurnsEvent = useCallback( + () => + addItem( + { + type: 'info', + text: + `The session has reached the maximum number of turns: ${config.getMaxSessionTurns()}. ` + + `Please update this limit in your setting.json file.`, + }, + Date.now(), + ), + [addItem, config], + ); + const processGeminiStreamEvents = useCallback( async ( stream: AsyncIterable, @@ -467,6 +481,9 @@ export const useGeminiStream = ( case ServerGeminiEventType.ToolCallResponse: // do nothing break; + case ServerGeminiEventType.MaxSessionTurns: + handleMaxSessionTurnsEvent(); + break; default: { // enforces exhaustive switch-case const unreachable: never = event; @@ -485,6 +502,7 @@ export const useGeminiStream = ( handleErrorEvent, scheduleToolCalls, handleChatCompressionEvent, + handleMaxSessionTurnsEvent, ], ); -- cgit v1.2.3