mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
Add integration test for maximum schema depth error handling (#5685)
This commit is contained in:
@@ -300,16 +300,14 @@ export class GeminiChat {
|
||||
};
|
||||
|
||||
response = await retryWithBackoff(apiCall, {
|
||||
shouldRetry: (error: Error) => {
|
||||
// Check for likely cyclic schema errors, don't retry those.
|
||||
if (error.message.includes('maximum schema depth exceeded'))
|
||||
return false;
|
||||
// Check error messages for status codes, or specific error names if known
|
||||
if (error && error.message) {
|
||||
shouldRetry: (error: unknown) => {
|
||||
// Check for known error messages and codes.
|
||||
if (error instanceof Error && error.message) {
|
||||
if (isSchemaDepthError(error.message)) return false;
|
||||
if (error.message.includes('429')) return true;
|
||||
if (error.message.match(/5\d{2}/)) return true;
|
||||
}
|
||||
return false;
|
||||
return false; // Don't retry other errors by default
|
||||
},
|
||||
onPersistent429: async (authType?: string, error?: unknown) =>
|
||||
await this.handleFlashFallback(authType, error),
|
||||
@@ -419,12 +417,10 @@ export class GeminiChat {
|
||||
// the stream. For simple 429/500 errors on initial call, this is fine.
|
||||
// If errors occur mid-stream, this setup won't resume the stream; it will restart it.
|
||||
const streamResponse = await retryWithBackoff(apiCall, {
|
||||
shouldRetry: (error: Error) => {
|
||||
// Check for likely cyclic schema errors, don't retry those.
|
||||
if (error.message.includes('maximum schema depth exceeded'))
|
||||
return false;
|
||||
// Check error messages for status codes, or specific error names if known
|
||||
if (error && error.message) {
|
||||
shouldRetry: (error: unknown) => {
|
||||
// Check for known error messages and codes.
|
||||
if (error instanceof Error && error.message) {
|
||||
if (isSchemaDepthError(error.message)) return false;
|
||||
if (error.message.includes('429')) return true;
|
||||
if (error.message.match(/5\d{2}/)) return true;
|
||||
}
|
||||
@@ -689,10 +685,7 @@ export class GeminiChat {
|
||||
private async maybeIncludeSchemaDepthContext(error: unknown): Promise<void> {
|
||||
// Check for potentially problematic cyclic tools with cyclic schemas
|
||||
// and include a recommendation to remove potentially problematic tools.
|
||||
if (
|
||||
isStructuredError(error) &&
|
||||
error.message.includes('maximum schema depth exceeded')
|
||||
) {
|
||||
if (isStructuredError(error) && isSchemaDepthError(error.message)) {
|
||||
const tools = (await this.config.getToolRegistry()).getAllTools();
|
||||
const cyclicSchemaTools: string[] = [];
|
||||
for (const tool of tools) {
|
||||
@@ -714,3 +707,8 @@ export class GeminiChat {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Visible for Testing */
|
||||
export function isSchemaDepthError(errorMessage: string): boolean {
|
||||
return errorMessage.includes('maximum schema depth exceeded');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user