mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-12 19:10:55 -07:00
fix(cli): revert breaking stream crash on limits to restore bot compatibility
This commit is contained in:
@@ -41,7 +41,6 @@ import {
|
||||
handleError,
|
||||
handleToolError,
|
||||
handleCancellationError,
|
||||
handleMaxTurnsExceededError,
|
||||
} from './utils/errors.js';
|
||||
import { TextOutput } from './ui/utils/textOutput.js';
|
||||
|
||||
@@ -400,6 +399,14 @@ export async function runNonInteractive({
|
||||
event.content?.[0]?.type === 'text'
|
||||
? event.content[0].text
|
||||
: 'Tool error';
|
||||
|
||||
if (event.data?.['errorType'] === ToolErrorType.STOP_EXECUTION) {
|
||||
const stopMessage = `Agent execution stopped: ${errorMsg}`;
|
||||
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
||||
process.stderr.write(`${stopMessage}\n`);
|
||||
}
|
||||
}
|
||||
|
||||
handleToolError(
|
||||
event.name,
|
||||
new Error(errorMsg),
|
||||
@@ -410,15 +417,6 @@ export async function runNonInteractive({
|
||||
displayText,
|
||||
);
|
||||
}
|
||||
if (
|
||||
event.isError &&
|
||||
event.data?.['errorType'] === ToolErrorType.STOP_EXECUTION
|
||||
) {
|
||||
const stopMessage = `Agent execution stopped: ${errorMsg}`;
|
||||
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
||||
process.stderr.write(`${stopMessage}\n`);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'error': {
|
||||
@@ -443,7 +441,19 @@ export async function runNonInteractive({
|
||||
if (event.reason === 'aborted') {
|
||||
handleCancellationError(config);
|
||||
} else if (event.reason === 'max_turns') {
|
||||
handleMaxTurnsExceededError(config);
|
||||
if (config.getOutputFormat() === OutputFormat.TEXT) {
|
||||
process.stderr.write(
|
||||
`[WARNING] Maximum session turns exceeded\n`,
|
||||
);
|
||||
}
|
||||
if (streamFormatter) {
|
||||
streamFormatter.emitEvent({
|
||||
type: JsonStreamEventType.ERROR,
|
||||
timestamp: new Date().toISOString(),
|
||||
severity: 'error',
|
||||
message: 'Maximum session turns exceeded',
|
||||
});
|
||||
}
|
||||
}
|
||||
// Emit final result
|
||||
if (streamFormatter) {
|
||||
|
||||
Reference in New Issue
Block a user