diff --git a/backend/internal/service/antigravity_gateway_service.go b/backend/internal/service/antigravity_gateway_service.go index 13c3eef6a0..14efabf1a4 100644 --- a/backend/internal/service/antigravity_gateway_service.go +++ b/backend/internal/service/antigravity_gateway_service.go @@ -1043,8 +1043,13 @@ func (s *AntigravityGatewayService) TestConnection(ctx context.Context, account // 复用 antigravityRetryLoop:完整的重试 / credits overages / 智能重试 prefix := fmt.Sprintf("[antigravity-Test] account=%d(%s)", account.ID, account.Name) + // 限制测试连接的总超时:避免 MODEL_CAPACITY_EXHAUSTED 60 次重试导致长时间阻塞 + const testConnectionTimeout = 30 * time.Second + testCtx, cancel := context.WithTimeout(ctx, testConnectionTimeout) + defer cancel() + p := antigravityRetryLoopParams{ - ctx: ctx, + ctx: testCtx, prefix: prefix, account: account, proxyURL: proxyURL,