fix(desktop,tui-gateway,zai): stop thinking-off from reverting to medium
A Z.ai desktop user reported thinking reverting to medium after one turn,
burning ~200% of a week's credits in 4 days despite reasoning_effort: false
in config.yaml. Four compounding bugs:
- _session_info reported reasoning_effort "" for disabled reasoning,
indistinguishable from unset — the desktop adopted it after the first
turn, wiping its sticky "thinking off" pick so every later chat
reverted to the default effort.
- config.set key=reasoning always wrote agent.reasoning_effort to global
config.yaml, so every desktop model-menu selection (preset.effort ??
'medium') clobbered the user's configured value. Now session-scoped
like the messaging gateway's /reasoning, landing on
create_reasoning_override so lazily-built sessions keep it too.
- YAML `reasoning_effort: false`/`off`/`no` (boolean False) was coerced
to "" by every loader's `str(x or "")`, silently re-enabling thinking.
parse_reasoning_effort now treats False/"false"/"disabled" as
{"enabled": False}; loaders (tui gateway, gateway, cli, cron,
delegate) pass the raw value through. The desktop config reader also
crashed on the boolean (false.trim()), aborting voice/STT settings.
- The zai provider profile never sent thinking on the wire, and GLM-4.5+
defaults to thinking ON server-side — so disabling reasoning was a
silent no-op on direct Z.ai, the actual token burner. The profile now
emits extra_body.thinking {"type": "enabled"|"disabled"} for
thinking-capable GLM models, mirroring the DeepSeek profile.
Also: /new (session reset) now carries reasoning_config across the
rebuild like model_override; config.get reasoning prefers the session's
live value and maps a config False to "none"; Settings shows "Off"
instead of a blank select for hand-written false.
This commit is contained in:
committed by
brooklyn!
parent
c3f06a8fda
commit
5a6720b884
@@ -436,6 +436,18 @@ class TestParseReasoningEffort:
|
||||
"""The literal "none" disables reasoning explicitly."""
|
||||
assert parse_reasoning_effort("none") == {"enabled": False}
|
||||
|
||||
@pytest.mark.parametrize("value", [False, "false", "FALSE", "disabled", " Disabled "])
|
||||
def test_false_aliases_disable_reasoning(self, value):
|
||||
"""YAML `reasoning_effort: false`/`off`/`no` reaches loaders as a
|
||||
boolean; users also hand-write "false"/"disabled". All must mean
|
||||
disabled — not "unset, fall back to the default and keep thinking"."""
|
||||
assert parse_reasoning_effort(value) == {"enabled": False}
|
||||
|
||||
@pytest.mark.parametrize("value", [None, True])
|
||||
def test_non_string_non_false_returns_none(self, value):
|
||||
"""None and boolean True fall back to the caller default."""
|
||||
assert parse_reasoning_effort(value) is None
|
||||
|
||||
@pytest.mark.parametrize("level", list(VALID_REASONING_EFFORTS))
|
||||
def test_each_valid_level(self, level):
|
||||
"""Every level listed in VALID_REASONING_EFFORTS is accepted as-is."""
|
||||
|
||||
Reference in New Issue
Block a user