fix(agents): don't auto-enable reasoning when thinking is active (#24290)

When thinking is set (e.g. thinking=low), the model produces internal
thinking blocks. The reasoning auto-default (based on model capability)
was formatting these blocks as "Reasoning:" text and delivering them to
WhatsApp/Telegram, leaking internal content to users.

Skip auto-enabling reasoning when thinkLevel is already set — the two
features serve the same purpose and enabling both causes the model's
internal thinking to be exposed as visible chat messages.

Users who explicitly set /reasoning on still get reasoning output.

Closes #24290

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Kay-051
2026-02-23 16:53:49 +08:00
committed by Nimrod Gutman
parent 89a4695020
commit 42795b87a3

View File

@@ -390,10 +390,14 @@ export async function resolveReplyDirectives(params: {
model = modelState.model;
// When neither directive nor session set reasoning, default to model capability (e.g. OpenRouter with reasoning: true).
// Skip auto-enabling when thinking is already active — the model's internal
// thinking blocks would otherwise be formatted and delivered as visible
// "Reasoning:" messages, leaking internal content to the user.
const reasoningExplicitlySet =
directives.reasoningLevel !== undefined ||
(sessionEntry?.reasoningLevel !== undefined && sessionEntry?.reasoningLevel !== null);
if (!reasoningExplicitlySet && resolvedReasoningLevel === "off") {
const thinkingActive = resolvedThinkLevel !== undefined && resolvedThinkLevel !== "off";
if (!reasoningExplicitlySet && resolvedReasoningLevel === "off" && !thinkingActive) {
resolvedReasoningLevel = await modelState.resolveDefaultReasoningLevel();
}