One of the consequences of Lucas' critique is that models must be microfounded. On the other side, Sonnenschein-Mantel-Debreu (SMD) theorem claims that microfoundation doesn't have any repercussion on aggregate economics. Then what does Lucas says about SMD? is there a counterargument to SMD? are there any additional conditions at the micro level to generate nice behaved aggregate demand?
Basically the Lucas solution to SMD was the representative agent (which brought its own problems).
Not everyone agrees that microfounding solves/addresses the Lucas critique:
My claim is that the current debate about DSGE models and the Lucas Critique should be understood through a historical perspective— namely, through the development, during the 1980s and 1990s, of two rival interpretations of Lucas (1976). On the one hand, the RBC approach advocated for what I will call a “theoretical interpretation” of the Critique; on the other hand, Keynesians championed what I will call an “empirical interpretation” of the Critique. These interpretations were rival with respect to their assessment of the following proposition: do microfoundations imply parameters’ stability?
[The] RBC approach argues that microfoundations do imply parameters’ stability. [...] Conversely, following the empirical interpretation of the Critique, Keynesians argue that microfoundations do not imply parameters’ stability.
Now if you're asking about Lucas himself, he did apparently see microfoundations as the/main answer, well apparently to everything that ailed macroeconomics:
The most interesting developments in macroeconomic theory seem to be describable as the reincorporation of aggregative problems such as inflation and the business cycle within the general framework of 'microeconomic' theory. If these developments succeed, the term 'macroeconomic' will simply disappear from use and the modifier 'micro' will become superfluous. We will simply speak, as did Smith, Ricardo, Marshall and Walras, of economic theory. If we are honest, we will have to face the fact that at any given time there will be phenomena that are well-understood from the point of view of the economic theory we have, and other phenomena that are not. We will be tempted, I am sure, to relieve the discomfort induced by discrepancies between theory and facts by saying that the ill-understood facts are the province of some other, different kind of economic theory. Keynesian 'macroeconomics' was, I think, a surrender (under great duress) to this temptation. It led to the abandonment, for a class of problems of great importance, of the use of the only 'engine for the discovery of truth' that we have in economics. (Lucas 1987, pp. 107-8)
However the Lucas research programme was hardly without flaws...
The theorems of Hugo Sonnenschein, Rolf Mantel and Gerard Debreu in the early 1970s established that the restrictions that generate well-behaved individual demand functions do not constrain aggregate demand functions to exhibit the same properties [...]. The new classicals sidestepped the problem of aggregation either by imagining an economy composed of identical individuals or by assuming that there is one individual who represents the whole economy, so that the solution to the optimization problem of this representative agent gives the aggregate relationships in that economy. In fact, they adopted the representative-agent model from the optimal-growth literature of the 1960s.
Using such models, Lucas and others developed the characteristic conclusions of the new classical school, such as the ineffectiveness of monetary policy with respect to the real economy (see Hoover 1988). Policy ineffectiveness was widely regarded by Keynesians as a politically conservative conclusion. Initially, it was interpreted as a direct consequence of the rational-expectations hypothesis, which was then regarded as politically suspect. Later, economists came to see that the assumptions of flexible prices and perfect competition were the critical factors in the policy ineffectiveness proposition. Once a wedge had been driven between policy ineffectiveness and the assumption of rational expectations, the rational expectations hypothesis was accepted by a wider spectrum of macroeconomists [...]. New Keynesians found that rational expectations did not rule out an important role for the government in stabilizing the economy.
In other words, in order to side-step SMD you can assume the representative agent and "microfound" on that, but that can give you worse headaches in terms of conclusions.
The hegemonic claims of microfoundations are most often justified with reference to the sort of problems highlighted by the Lucas critique. But what justifies the hegemony of the representative agent? Mainstream macroeconomists are rarely explicit on this question; but, implicitly, the argument seems to be that the assumption of a representative, optimizing, agent is mainly technical – both a compromise between the ambitions and the computational capacities of the macroeconomist and a convenient way to introduce a welfare measure for the evaluation of economic policy. The implicit argument is what Hoover refers to as “eschatological justification”: “the representative-agent model is but the starting point for a series of fuller and richer models that eventually will provide the basis for an adequate macromodel, and that, therefore, the current generation of models is entitled to credence” (Hoover 2006: 146 [...]
The representative-agent program elevates the claims of microeconomics in some version or other to the utmost importance, while at the same time not acknowledging that the very microeconomic theory it privileges undermines, in the guise of the Sonnenschein–Debreu–Mantel theorem, the likelihood that the utility function of the representative agent will be any direct analogue of a plausible utility function for an individual agent. Kirman’s (1992) survey article on the representative agent, which highlights the lack of analogy, is well-cited; yet, it is striking that almost all of the citations are by critics of the representative-agent program; there is little evidence that advocates have even noticed the argument against their approach.
Solow was one of the critics of the representative-agent approach. In response:
Chari and Kehoe responded to the criticisms by Solow that they considered of substance. They recognize that the challenges facing modern macroeconomics are not small, but reject Solow’s criticisms to the use of a representative agent and to their claim that macroeconomics is now firmly grounded in economic theory. With respect to the representative agent hypothesis, Chari and Kehoe (2008: 247) state that modern macroeconomics does not end with such hypothesis, and in fact it does not end “too far from where Solow prefers”: “Most of macroeconomic research over the last 20 years has precisely been about incorporating the heterogeneity and the rich interactions that Solow seems to think it needs.” They argue that macroeconomists just start with a representative agent and then enrich the model “with the detail necessary to answer the question at hand” (p. 248). They also criticize Solow for his use in his growth papers of a single production function with aggregate labor and stock of capital, with which he “sacrificed realism for an abstraction that has proven invaluable” (p. 247)
The more recent works cited there:
Solow, Robert M. (2008). The State of Macroeconomics. Journal of Economic Perspectives, 22 (1):243–6
Chari, V. V., and Patrick J. Kehoe (2006). Modern Macroeconomics in Practice: How Theory Is Shaping Policy. Journal of Economic Perspectives, 20 (4):3–28.
Chari, V. V., and Patrick J. Kehoe (2008). Response from V. V. Chari and Patrick J. Kehoe. Journal of Economic Perspectives, 22 (1):247–9.
Also, the representative-agent approach has pretty much become identified with DGSE:
All the different views mainstream macroeconomists have about the state of their field and about possible areas of improvement should not diminish the degree to which they converged methodologically in studying fluctuations. They all analyse such phenomena usually through a dynamic stochastic general equilibrium model with a representative agent, firmly grounded on microeconomic principles. Moreover, several of them agree with Chari (2010: 2) that “any interesting model must be a dynamic stochastic general equilibrium model. From this perspective, there is no other game in town.” Therefore, he continues, “a useful aphorism in macroeconomics is: ‘If you have an interesting and coherent story to tell, you can tell it in a DSGE model. If you cannot, your story is incoherent.’”
See What is the appeal of DSGE models? for further on DGSE's success story.
But of course there comes the (nearly standard now, post-2008) critique:
The representative-agent (RA) assumption prevent DSGE models to address distributional issues, which are one of the major cause of the Great Recession and they are fundamental for studying the effects of policies. [...]
The RA assumption coupled with the implicit presence of a Walrasian auctioneer, which sets prices before exchanges take place, rule out almost by definition the possibility of interactions carried out by heterogeneous individuals. This prevents DSGE model to accurately study the dynamics of credit and financial markets. Indeed, the assumption that the representative agent always satisfies the transversality condition, removes the default risk from DSGE models (Goodhart, 2009). As a consequence, agents face the same interest rate (no risk premia) and all transactions can be undertaken in capital markets without the need of banks. The abstraction from default risks does not allow DSGE models to contemplate the conflict between price and financial stability that Central Banks always face (Howitt, 2011): they just care about the nth-order distortions caused by price misallignments which can eventually result in inflation without considering the huge costs of financial crisis (Stiglitz, 2011, 2015). No surprise that DSGE models work fine in normal time but they are unequipped not only to forecast but also to explain the current crisis (Goodhart, 2009; Krugman, 2011)
There is a bit more subtlety to RA than what I've covered here; RA can include some sources of parametric heterogeneity but assumes a sort of "structural" homogeneity, if I understand that correctly.
I think that one solution to Lucas' critique is to micro-found your econometric model, but his critique is broader. I think it means that if you don't consider seriously that agents are optimizing, you may assume that some parameters will be invariant to policy changes, when they may not be. If SMD states that when looking at aggregate data, some properties of individual agent models do not follow, then this can be reflected in your econometric model so that your model is still not assuming some parameters to be policy invariant when they are not. I don't really see any tension between these two.