修复首次会话等待与上游饱和重试

This commit is contained in:
2026-08-12 23:26:19 +08:00
parent b02c3f22e1
commit 08da976634
10 changed files with 506 additions and 14 deletions

View File

@@ -9,6 +9,7 @@ import {
import { proxyAwareFetch } from '../../utils/proxy-fetch';
import { logger } from '../../utils/logger';
import { getOpencodeErrorKind } from '../../../shared/opencode-error-kind';
import { isOpencodeUpstreamSaturated } from '../../../shared/opencode-error-details';
const AI_PROXY_PREFIX = '/api/ai-proxy/v1';
const MAX_ERROR_LOG_MESSAGE_LENGTH = 600;
@@ -81,6 +82,9 @@ function getForwardedOneApiStatus(status: number, bodyText: string): number {
if (status === 429 && getOpencodeErrorKind(bodyText) === 'quota_exhausted') {
return 402;
}
if (status === 429 && isOpencodeUpstreamSaturated(bodyText)) {
return 400;
}
return status;
}