openclaw/src
Liu Yuan 97b3ee7ec0 Fix: Honor `/think off` for reasoning-capable models
Problem:
When users execute `/think off`, they still receive `reasoning_content`
from models configured with `reasoning: true` (e.g., GLM-4.7, GLM-4.6,
Kimi K2.5, MiniMax-M2.1).

Expected: `/think off` should completely disable reasoning content.
Actual: Reasoning content is still returned.

Root Cause:
The directive handlers delete `sessionEntry.thinkingLevel` when user
executes `/think off`. This causes the thinking level to become undefined,
and the system falls back to `resolveThinkingDefault()`, which checks the
model catalog and returns "low" for reasoning-capable models, ignoring the
user's explicit intent.

Why We Must Persist "off" (Design Rationale):

1. **Model-dependent defaults**: Unlike other directives where "off" means
   use a global default, `thinkingLevel` has model-dependent defaults:
   - Reasoning-capable models (GLM-4.7, etc.) → default "low"
   - Other models → default "off"

2. **Existing pattern**: The codebase already follows this pattern for
   `elevatedLevel`, which persists "off" explicitly to override defaults
   that may be "on". The comment explains:
   "Persist 'off' explicitly so `/elevated off` actually overrides defaults."

3. **User intent**: When a user explicitly executes `/think off`, they want
   to disable thinking regardless of the model's capabilities. Deleting the
   field breaks this intent by falling back to the model's default.

Solution:
Persist "off" value instead of deleting the field in all internal directive handlers:
- `src/auto-reply/reply/directive-handling.impl.ts`: Directive-only messages
- `src/auto-reply/reply/directive-handling.persist.ts`: Inline directives
- `src/commands/agent.ts`: CLI command-line flags

Gateway API Backward Compatibility:
The original implementation incorrectly mapped `null` to "off" in
`sessions-patch.ts` for consistency with internal handlers. This was a
breaking change because:
- Previously, `null` cleared the override (deleted the field)
- API clients lost the ability to "clear to default" via `null`
- This contradicts standard JSON semantics where `null` means "no value"

Restored original null semantics in `src/gateway/sessions-patch.ts`:
- `null` → delete field, fall back to model default (clear override)
- `"off"` → persist explicit override
- Other values → normalize and persist

This ensures backward compatibility for API clients while fixing the `/think off`
issue in internal handlers.

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
2026-02-09 16:08:15 -08:00
..
acp chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
agents feat: adding support for Together ai provider (#10304) 2026-02-10 08:49:34 +09:00
auto-reply Fix: Honor `/think off` for reasoning-capable models 2026-02-09 16:08:15 -08:00
browser refactor: consolidate duplicate utility functions (#12439) 2026-02-08 23:59:43 -08:00
canvas-host fix: use STATE_DIR instead of hardcoded ~/.openclaw for identity and canvas (#4824) 2026-02-07 22:16:59 -05:00
channels TypeScript: add extensions to tsconfig and fix type errors (#12781) 2026-02-09 10:05:38 -08:00
cli feat: adding support for Together ai provider (#10304) 2026-02-10 08:49:34 +09:00
commands Fix: Honor `/think off` for reasoning-capable models 2026-02-09 16:08:15 -08:00
compat refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
config (fix): .env vars not available during runtime config reloads (healthchecks fail with MissingEnvVarError) (#12748) 2026-02-09 16:31:41 -06:00
cron fix(cron): recover flat params when LLM omits job wrapper (#12124) 2026-02-08 23:10:09 -08:00
daemon fix(runtime): bump minimum Node.js version to 22.12.0 (#5370) 2026-02-05 13:42:52 -08:00
discord fix(routing): make bindings dynamic by calling loadConfig() per-message (#11372) 2026-02-09 00:34:55 -06:00
docs Docs: landing page revamp (#8885) 2026-02-04 10:37:14 -05:00
gateway Fix: Honor `/think off` for reasoning-capable models 2026-02-09 16:08:15 -08:00
hooks fix: use STATE_DIR instead of hardcoded ~/.openclaw for identity and canvas (#4824) 2026-02-07 22:16:59 -05:00
imessage refactor: unify peer kind to ChatType, rename dm to direct (#11881) 2026-02-09 09:20:52 +09:00
infra test(auth): cover key normalization 2026-02-09 11:58:18 -06:00
line refactor: unify peer kind to ChatType, rename dm to direct (#11881) 2026-02-09 09:20:52 +09:00
link-understanding chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
logging fix: guard resolveUserPath against undefined input (#10176) 2026-02-06 13:16:58 -05:00
macos chore: Enable "curly" rule to avoid single-statement if confusion/errors. 2026-01-31 16:19:20 +09:00
markdown chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
media refactor: consolidate PNG encoder and safeParseJson utilities (#12457) 2026-02-09 00:21:54 -08:00
media-understanding refactor: unify peer kind to ChatType, rename dm to direct (#11881) 2026-02-09 09:20:52 +09:00
memory refactor: consolidate duplicate utility functions (#12439) 2026-02-08 23:59:43 -08:00
node-host fix: harden Windows exec allowlist 2026-02-03 09:34:25 -08:00
pairing refactor: consolidate PNG encoder and safeParseJson utilities (#12457) 2026-02-09 00:21:54 -08:00
plugin-sdk TypeScript: add extensions to tsconfig and fix type errors (#12781) 2026-02-09 10:05:38 -08:00
plugins fix: improve code-size gate output and duplicate detection, fix Windows path in source-display 2026-02-09 13:18:51 -08:00
process fix: skip extension append if command already has one 2026-01-31 20:39:33 -06:00
providers chore: Fix failing test. 2026-02-09 09:58:58 +09:00
routing refactor: unify peer kind to ChatType, rename dm to direct (#11881) 2026-02-09 09:20:52 +09:00
scripts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
security Tests: harden flake hotspots and consolidate provider-auth suites (#11598) 2026-02-07 21:32:23 -05:00
sessions chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
shared/text chore: Enable "curly" rule to avoid single-statement if confusion/errors. 2026-01-31 16:19:20 +09:00
signal refactor: unify peer kind to ChatType, rename dm to direct (#11881) 2026-02-09 09:20:52 +09:00
slack refactor: unify peer kind to ChatType, rename dm to direct (#11881) 2026-02-09 09:20:52 +09:00
telegram fix(telegram): add DM allowFrom regression tests 2026-02-09 22:59:47 +05:30
terminal fix: error handling in restore failure reporting 2026-02-03 06:22:51 +00:00
test-helpers fix: use STATE_DIR instead of hardcoded ~/.openclaw for identity and canvas (#4824) 2026-02-07 22:16:59 -05:00
test-utils chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
tts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
tui Centralize date/time formatting utilities (#11831) 2026-02-08 04:53:31 -08:00
types fix: update pi packages to 0.51.0, remove bogus type augmentation 2026-02-02 01:52:33 +01:00
utils fix(auth): strip line breaks from pasted keys 2026-02-09 11:26:27 -06:00
web fix: preserve original filename for WhatsApp inbound documents (#12691) 2026-02-09 16:56:19 -05:00
whatsapp chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
wizard fix(onboarding): auto-install shell completion in QuickStart 2026-02-09 12:56:12 -06:00
channel-web.barrel.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
channel-web.ts
docker-setup.test.ts refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
entry.ts Centralize date/time formatting utilities (#11831) 2026-02-08 04:53:31 -08:00
extensionAPI.ts chore: Migrate to tsdown, speed up JS bundling by ~10x (thanks @hyf0). 2026-02-03 20:18:16 +09:00
globals.test.ts
globals.ts chore: Enable "curly" rule to avoid single-statement if confusion/errors. 2026-01-31 16:19:20 +09:00
index.test.ts
index.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
logger.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
logger.ts chore: Enable "curly" rule to avoid single-statement if confusion/errors. 2026-01-31 16:19:20 +09:00
logging.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
polls.test.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
polls.ts
runtime.ts CLI: restore terminal state on exit 2026-02-03 06:10:19 +00:00
utils.test.ts fix(paths): structurally resolve home dir to prevent Windows path bugs (#12125) 2026-02-08 20:06:29 -05:00
utils.ts refactor: consolidate PNG encoder and safeParseJson utilities (#12457) 2026-02-09 00:21:54 -08:00
version.test.ts fix: CLI harden update restart imports and fix nested bundle version resolution 2026-02-06 00:09:48 -05:00
version.ts fix: CLI harden update restart imports and fix nested bundle version resolution 2026-02-06 00:09:48 -05:00