setting of Lagrangian function Consider a simple consumer's problem:
Max $u(X)$ s.t.  $\sum_i^l p_i x_i\leq \sum_i^l p_i w_i$
$w$ is initial endowment.
We can set the Lagrangian function to solve this problem.
$L=u(X)+\lambda (  \sum_i^l p_i w_i +\sum_i^l p_i x_i)$
But some may set the Lagrangian function as differenct way.
$L=u(X)+\lambda (  \sum_i^l p_i x_i -\sum_i^l p_i w_i)$
The result of calculation is same except the sign of Lagrangian multiplier $\lambda$
For the consumer's problem, which way is correct?
Edit after comment: There is a typo at the first equation in this
question. $\sum_i^l p_i w_i +\sum_i^l p_i x_i$ should be changed as
$\sum_i^l p_i w_i -\sum_i^l p_i x_i$
It's a matter of choice how one writes the Lagrangian in the context of Lagrange/KKT. Depending on how it's written, the gradients of the objective and constraint functions are either parallel or anti-parallel at a (suitable) optimum, and the Lagrange multiplier is neither negative or positive. At the end of the day, it is the same (subset of) optima that are covered by the Lagrangian FOC.
However, there is a standard choice---sometimes called the standard form in optimization literature---that ensures the Lagrange multipliers $\lambda$'s are non-negative. (See, for example, Convex Optimization by Boyd and Vandenberghe.)
In the standard form, the Lagranian is always written in such a way that it improves the objective function.
This convention is not always pointed out/followed in economics texts.
When it is followed in economic contexts, then the Lagrange multipliers admit the usual interpretation as marginal values of the corresponding constraints---a kind of &quot;indirect marginal utility&quot;. E.g. the standard-form Lagrange multiplier is the derivative of the indirect utility function with respect to wealth---which must be non-negative.
For example, consider the maximization problem
$$
\max_{g(x) \geq 0} u(x) 
$$
where $u : \mathbb{R}^n \rightarrow \mathbb{R}$ and $g : \mathbb{R}^n \rightarrow \mathbb{R}^p$. E.g. in a consumer's problem, $u$ is utility function, $p = 1$, and $g(x) = p^T(w-x)$.
Then the standard form Lagrangian is
$$
L(x, \lambda) = u(x) + \lambda^T g(x).
$$
It improves the objective function $u$ when $\lambda \geq 0$. This means that, for maximization problems, $L(x, \lambda) \geq u(x)$ for all $x$ and all $\lambda \geq 0$.
Since you're trying to maximize $u$, improving on $u$ means being larger than $u$.

In the standard form, the Lagrange multiplers must be non-negative., i.e. at an (suitable) optimum $x^*$, we must have $D u(x^*) + \lambda^T D g(x^*) = 0$ for some $\lambda$ with non-negative entries. This is easy to see, especially in the case of single constraint $p = 1$. If constraint $g$ is slack, then $\lambda  = 0$. If $g$ binds, then the gradient $D g(x^*)$ must point toward the interior $\{ g &gt; 0 \}$. On the other hand, $D u(x^*)$ cannot point toward the interior---otherwise there would be an optimum in the interior. So $D u(x^*)$ and $D g(x^*)$ are anti-parallel and $\lambda &gt; 0$.

If the maximization problem is formulated as
$$
\max_{g(x) \leq 0} u(x) 
$$
then the standard form Lagrangian is $L(x, \lambda) = u(x) - \lambda^T g(x)$. Again, $L$ is written in such a way that, when $\lambda$ is non-negative, $L$ improves $u$.
Similar for a minimization problem.

&quot;Suitability&quot; of an optimum means that $D g(x^*)$ must be full-rank. This type of condition is called constraint qualification. The general KKT theorem says that the Lagrangian FOC is a necessary condition for local optima where constraint qualification holds. When the objective function is concave or quasi-concave (convex or quasi-conconvex, for minimization), then constraint qualification is not needed and Lagrangian FOC is sufficient for global optima.