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

@@ -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<GeminiEvent>,
@@ -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,
],
);