lithe-cli 0.8.2__tar.gz → 0.8.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of lithe-cli might be problematic. Click here for more details.
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/PKG-INFO +10 -2
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/README.md +8 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli/__init__.py +1 -1
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli/agent.py +1 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli/commands.py +1 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli/config.py +11 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli/main.py +9 -1
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli/profiles.py +16 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli/ttui.py +52 -5
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli/tui.py +53 -4
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli/workbench.py +67 -6
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli.egg-info/PKG-INFO +10 -2
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli.egg-info/requires.txt +1 -1
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/pyproject.toml +1 -1
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/tests/test_profiles.py +21 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/tests/test_ttui.py +49 -1
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/tests/test_tui_v2.py +15 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/tests/test_workbench.py +63 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/LICENSE +0 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli/__main__.py +0 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli/prompts.py +0 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli/py.typed +0 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli/sessions.py +0 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli/setup.py +0 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli/ui.py +0 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli.egg-info/SOURCES.txt +0 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli.egg-info/dependency_links.txt +0 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli.egg-info/entry_points.txt +0 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/lithe_cli.egg-info/top_level.txt +0 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/setup.cfg +0 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/tests/test_cli.py +0 -0
- {lithe_cli-0.8.2 → lithe_cli-0.8.4}/tests/test_cli_sessions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lithe-cli
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.4
|
|
4
4
|
Summary: Command-line interface for the lithe agent kernel: chat, one-shot runs, undo, and run inspection.
|
|
5
5
|
License: MIT License
|
|
6
6
|
|
|
@@ -39,7 +39,7 @@ Classifier: Typing :: Typed
|
|
|
39
39
|
Requires-Python: >=3.10
|
|
40
40
|
Description-Content-Type: text/markdown
|
|
41
41
|
License-File: LICENSE
|
|
42
|
-
Requires-Dist: lithe>=0.9.
|
|
42
|
+
Requires-Dist: lithe>=0.9.18
|
|
43
43
|
Requires-Dist: prompt-toolkit>=3.0.38
|
|
44
44
|
Requires-Dist: textual>=1.0
|
|
45
45
|
Provides-Extra: dev
|
|
@@ -222,6 +222,14 @@ turning `shell` on restates its trust warning. `/tools` re-derives the
|
|
|
222
222
|
registry after a capability flip, so the listing always matches what the
|
|
223
223
|
next turn will see.
|
|
224
224
|
|
|
225
|
+
**Reasoning intensity**: `/reasoning` (or `F6`) picks a level —
|
|
226
|
+
`off / minimal / low / medium / high`, or any value your model accepts
|
|
227
|
+
(`none` on some) typed directly; `--save` persists it to the profile. The
|
|
228
|
+
kernel maps it per protocol (`reasoning_effort` on chat-completions,
|
|
229
|
+
`reasoning.effort` on Responses) and combines it with
|
|
230
|
+
`extra_body["reasoning"]` siblings such as OpenRouter's
|
|
231
|
+
`max_tokens`/`exclude`. The sidebar shows the active level when set.
|
|
232
|
+
|
|
225
233
|
### Extra capabilities
|
|
226
234
|
|
|
227
235
|
The kernel ships these as bundles; the CLI grants them per flag:
|
|
@@ -173,6 +173,14 @@ turning `shell` on restates its trust warning. `/tools` re-derives the
|
|
|
173
173
|
registry after a capability flip, so the listing always matches what the
|
|
174
174
|
next turn will see.
|
|
175
175
|
|
|
176
|
+
**Reasoning intensity**: `/reasoning` (or `F6`) picks a level —
|
|
177
|
+
`off / minimal / low / medium / high`, or any value your model accepts
|
|
178
|
+
(`none` on some) typed directly; `--save` persists it to the profile. The
|
|
179
|
+
kernel maps it per protocol (`reasoning_effort` on chat-completions,
|
|
180
|
+
`reasoning.effort` on Responses) and combines it with
|
|
181
|
+
`extra_body["reasoning"]` siblings such as OpenRouter's
|
|
182
|
+
`max_tokens`/`exclude`. The sidebar shows the active level when set.
|
|
183
|
+
|
|
176
184
|
### Extra capabilities
|
|
177
185
|
|
|
178
186
|
The kernel ships these as bundles; the CLI grants them per flag:
|
|
@@ -100,6 +100,7 @@ def build_llm(cfg: Config) -> LLMConfig:
|
|
|
100
100
|
"attempts": cfg.attempts,
|
|
101
101
|
"stream": cfg.stream,
|
|
102
102
|
"context_window": cfg.context_window,
|
|
103
|
+
"reasoning_effort": cfg.reasoning_effort,
|
|
103
104
|
}
|
|
104
105
|
# The CLI's transport field defaults to "chat" and is only overridden by
|
|
105
106
|
# offline tests (custom transports); the default must not clobber a
|
|
@@ -22,6 +22,7 @@ COMMANDS: dict[str, tuple[str, str]] = {
|
|
|
22
22
|
"rename": ("标题", "重命名当前会话"),
|
|
23
23
|
"model": ("[名称|--save]", "查看/切换模型(F4 同效);--save 同时存为档案默认"),
|
|
24
24
|
"models": ("", "从端点拉取模型列表并缓存"),
|
|
25
|
+
"reasoning": ("[级别|--save]", "查看/设置推理强度(F6 同效);off/minimal/low/medium/high,下一轮生效"),
|
|
25
26
|
"profile": ("[名称]", "查看/切换 provider 档案"),
|
|
26
27
|
"set": ("[名称] [值]", "查看/调整运行设置(F5 同效);开关项回车或 on/off,下一轮生效"),
|
|
27
28
|
"tools": ("", "列出已注册的工具"),
|
|
@@ -80,6 +80,10 @@ class Config:
|
|
|
80
80
|
# Wire protocol ("chat" | "responses") or a custom LLMTransport instance.
|
|
81
81
|
# Not exposed as a flag: the injection point for offline tests.
|
|
82
82
|
transport: Any = "chat"
|
|
83
|
+
# Reasoning intensity (None = send nothing; "off" normalizes to None at
|
|
84
|
+
# load). Passed verbatim to the kernel's reasoning_effort — which values
|
|
85
|
+
# the current model accepts is the endpoint's call.
|
|
86
|
+
reasoning_effort: str | None = None
|
|
83
87
|
|
|
84
88
|
@property
|
|
85
89
|
def has_endpoint(self) -> bool:
|
|
@@ -260,6 +264,11 @@ def load_config(args: Any) -> Config:
|
|
|
260
264
|
f"provider {provider!r} 的 preset 未提供 base_url;"
|
|
261
265
|
f"请在档案中手写 base_url。"
|
|
262
266
|
)
|
|
267
|
+
# Reasoning effort: flag > saved profile field; "off" normalizes to None
|
|
268
|
+
# (send nothing). An in-session /reasoning overrides both.
|
|
269
|
+
effort = g("reasoning_effort", None) or saved.get("reasoning_effort")
|
|
270
|
+
if effort is not None and effort.strip().lower() == "off":
|
|
271
|
+
effort = None
|
|
263
272
|
return Config(
|
|
264
273
|
api_key=(
|
|
265
274
|
g("api_key", None) or os.environ.get(ENV_API_KEY) or saved.get("api_key")
|
|
@@ -268,6 +277,8 @@ def load_config(args: Any) -> Config:
|
|
|
268
277
|
model=(g("model", None) or os.environ.get(ENV_MODEL) or saved.get("model")),
|
|
269
278
|
profile=active,
|
|
270
279
|
provider=provider,
|
|
280
|
+
reasoning_effort=(effort.strip() if isinstance(effort, str) and effort.strip()
|
|
281
|
+
else None),
|
|
271
282
|
store_dir=store_dir,
|
|
272
283
|
workspace_dir=workspace_dir,
|
|
273
284
|
user_id=g("user", None) or DEFAULT_USER,
|
|
@@ -144,6 +144,13 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
144
144
|
sp.add_argument(
|
|
145
145
|
"--attempts", type=int, default=2, help="per-call retry attempts"
|
|
146
146
|
)
|
|
147
|
+
sp.add_argument(
|
|
148
|
+
"--reasoning-effort",
|
|
149
|
+
metavar="LEVEL",
|
|
150
|
+
default=None,
|
|
151
|
+
help="reasoning intensity (off/minimal/low/medium/high, model "
|
|
152
|
+
"dependent; profile field reasoning_effort; in-session /reasoning)",
|
|
153
|
+
)
|
|
147
154
|
|
|
148
155
|
run_p = sub.add_parser("run", help="run one task")
|
|
149
156
|
runtime(run_p)
|
|
@@ -611,7 +618,8 @@ def _run_textual(cfg: Any, task: str | None, mode: str, args: Any) -> int:
|
|
|
611
618
|
f"Textual 前端不可用({exc})。pip install textual,"
|
|
612
619
|
"或用 --ui prompt 走旧版界面。"
|
|
613
620
|
) from exc
|
|
614
|
-
|
|
621
|
+
# run_textual_screen is sync: it drives its own asyncio.run inside.
|
|
622
|
+
return run_textual_screen(cfg, task, mode, args)
|
|
615
623
|
|
|
616
624
|
|
|
617
625
|
def main(argv: list[str] | None = None) -> int:
|
|
@@ -62,6 +62,9 @@ def _clean_endpoint(data: dict) -> dict:
|
|
|
62
62
|
provider = data.get("provider")
|
|
63
63
|
if isinstance(provider, str) and provider.strip():
|
|
64
64
|
out["provider"] = provider.strip()
|
|
65
|
+
effort = data.get("reasoning_effort")
|
|
66
|
+
if isinstance(effort, str) and effort.strip():
|
|
67
|
+
out["reasoning_effort"] = effort.strip()
|
|
65
68
|
for k in ("context_window",):
|
|
66
69
|
v = data.get(k)
|
|
67
70
|
if isinstance(v, int) and v > 0:
|
|
@@ -209,6 +212,19 @@ class ProfileStore:
|
|
|
209
212
|
self._save(data["active"], data["profiles"])
|
|
210
213
|
return True
|
|
211
214
|
|
|
215
|
+
def set_reasoning_effort(self, name: str, effort: str | None) -> bool:
|
|
216
|
+
"""Set (or clear, with None/"off") a profile's reasoning effort."""
|
|
217
|
+
data = self.load()
|
|
218
|
+
if name not in data["profiles"]:
|
|
219
|
+
return False
|
|
220
|
+
endpoint = data["profiles"][name]
|
|
221
|
+
if effort is None or effort.strip().lower() == "off":
|
|
222
|
+
endpoint.pop("reasoning_effort", None)
|
|
223
|
+
else:
|
|
224
|
+
endpoint["reasoning_effort"] = effort.strip()
|
|
225
|
+
self._save(data["active"], data["profiles"])
|
|
226
|
+
return True
|
|
227
|
+
|
|
212
228
|
def cache_models(self, name: str, models: list[str]) -> bool:
|
|
213
229
|
data = self.load()
|
|
214
230
|
if name not in data["profiles"]:
|
|
@@ -70,6 +70,8 @@ def sidebar_markup(state: TuiState) -> str:
|
|
|
70
70
|
out.append("[dim]◆ 模型[/]")
|
|
71
71
|
label = f"{state.profile} · {state.model}" if state.profile else state.model
|
|
72
72
|
out.append(f"[cyan]{label}[/]")
|
|
73
|
+
if state.reasoning_effort:
|
|
74
|
+
out.append(f"[dim]推理 {state.reasoning_effort} · F6 切换[/]")
|
|
73
75
|
if state.context_window:
|
|
74
76
|
out.append(f"[dim]窗口 {state.context_window:,} · F4 切换[/]")
|
|
75
77
|
else:
|
|
@@ -131,9 +133,9 @@ def sidebar_markup(state: TuiState) -> str:
|
|
|
131
133
|
|
|
132
134
|
def footer_text(state: TuiState) -> str:
|
|
133
135
|
if state.running:
|
|
134
|
-
return f" ● {state.status} · Ctrl+C 取消 · F3 会话 · F4 模型 ·
|
|
136
|
+
return f" ● {state.status} · Ctrl+C 取消 · F3 会话 · F4 模型 · F6 推理 "
|
|
135
137
|
return (f" ● {state.status} · Enter 发送 · F2 侧栏 · F3 会话 · F4 模型"
|
|
136
|
-
f" · F5 设置 · /help ")
|
|
138
|
+
f" · F5 设置 · F6 推理 · /help ")
|
|
137
139
|
|
|
138
140
|
|
|
139
141
|
# -- input: completion + persistent history ------------------------------------
|
|
@@ -345,6 +347,7 @@ class LitheApp(App):
|
|
|
345
347
|
Binding("f3", "open_sessions", "会话", priority=True),
|
|
346
348
|
Binding("f4", "open_model", "模型", priority=True),
|
|
347
349
|
Binding("f5", "open_set", "设置", priority=True),
|
|
350
|
+
Binding("f6", "open_reasoning", "推理", priority=True),
|
|
348
351
|
Binding("ctrl+c", "cancel_or_exit", "取消/退出", priority=True),
|
|
349
352
|
]
|
|
350
353
|
|
|
@@ -436,6 +439,7 @@ class LitheApp(App):
|
|
|
436
439
|
st = self.state
|
|
437
440
|
st.model = self.cfg.model or "(scripted)"
|
|
438
441
|
st.profile = self.cfg.profile or ""
|
|
442
|
+
st.reasoning_effort = self.cfg.reasoning_effort
|
|
439
443
|
if self.wb.current is not None:
|
|
440
444
|
st.session_id = self.wb.current["id"]
|
|
441
445
|
st.session_title = self.wb.current.get("title") or ""
|
|
@@ -587,7 +591,7 @@ class LitheApp(App):
|
|
|
587
591
|
return
|
|
588
592
|
if r.awaitable is not None:
|
|
589
593
|
asyncio.create_task(r.awaitable())
|
|
590
|
-
if r.overlay in ("sessions", "model", "set"):
|
|
594
|
+
if r.overlay in ("sessions", "model", "set", "reasoning"):
|
|
591
595
|
self._open_picker(r.overlay)
|
|
592
596
|
if r.overlay == "rebuild" and self._current_cid() is not None:
|
|
593
597
|
self._activate(self._current_cid())
|
|
@@ -657,15 +661,33 @@ class LitheApp(App):
|
|
|
657
661
|
f"{row['key']:<10} {shown:<4}{row['label']}",
|
|
658
662
|
))
|
|
659
663
|
else:
|
|
664
|
+
shown = "off" if value is None else value
|
|
660
665
|
items.append((
|
|
661
666
|
{"kind": "hint"},
|
|
662
|
-
f" {row['key']:<10} {
|
|
667
|
+
f" {row['key']:<10} {shown!s:<6}{row['label']}"
|
|
663
668
|
f"(/set {row['key']} 值)",
|
|
664
669
|
))
|
|
665
670
|
self.push_screen(PickerModal(
|
|
666
671
|
"运行设置", items,
|
|
667
672
|
"Enter 切换开关 · 数值项用 /set 名称 值 · Esc 关闭",
|
|
668
673
|
), self._set_picked)
|
|
674
|
+
elif name == "reasoning":
|
|
675
|
+
from .workbench import REASONING_LEVELS
|
|
676
|
+
|
|
677
|
+
current = self.cfg.reasoning_effort or "off"
|
|
678
|
+
items = []
|
|
679
|
+
for level in REASONING_LEVELS:
|
|
680
|
+
active = level == current
|
|
681
|
+
label = {"off": "关闭(不发送该字段)"}.get(level, level)
|
|
682
|
+
items.append((
|
|
683
|
+
{"level": level},
|
|
684
|
+
f"{'[green]●[/] ' if active else ' '}{label}",
|
|
685
|
+
))
|
|
686
|
+
self.push_screen(PickerModal(
|
|
687
|
+
"推理强度", items,
|
|
688
|
+
"Enter 应用 · s 存为档案默认 · Esc 关闭",
|
|
689
|
+
letter_actions={"s": "_picker_save_reasoning"},
|
|
690
|
+
), self._reasoning_picked)
|
|
669
691
|
|
|
670
692
|
def action_open_sessions(self) -> None:
|
|
671
693
|
if self.mode == "chat" and not isinstance(self.screen, PickerModal):
|
|
@@ -679,18 +701,43 @@ class LitheApp(App):
|
|
|
679
701
|
if not isinstance(self.screen, PickerModal):
|
|
680
702
|
self._open_picker("set")
|
|
681
703
|
|
|
704
|
+
def action_open_reasoning(self) -> None:
|
|
705
|
+
if not isinstance(self.screen, PickerModal):
|
|
706
|
+
self._open_picker("reasoning")
|
|
707
|
+
|
|
708
|
+
def _reasoning_picked(self, result) -> None:
|
|
709
|
+
if not result or result[0] != "select" or not result[1]:
|
|
710
|
+
return
|
|
711
|
+
r = self.wb.set_reasoning(result[1]["level"])
|
|
712
|
+
for cls, text in r.messages:
|
|
713
|
+
self.state.say(cls, text)
|
|
714
|
+
self._refresh_meta()
|
|
715
|
+
self._refresh_chrome()
|
|
716
|
+
self._sync_feed()
|
|
717
|
+
|
|
718
|
+
def _picker_save_reasoning(self, payload) -> None:
|
|
719
|
+
if not payload:
|
|
720
|
+
return
|
|
721
|
+
r = self.wb.set_reasoning(payload.get("level", ""), save=True)
|
|
722
|
+
for cls, text in r.messages:
|
|
723
|
+
self.state.say(cls, text)
|
|
724
|
+
self._refresh_meta()
|
|
725
|
+
self._refresh_chrome()
|
|
726
|
+
self._sync_feed()
|
|
727
|
+
|
|
682
728
|
def _set_picked(self, result) -> None:
|
|
683
729
|
if not result or result[0] != "select" or not result[1]:
|
|
684
730
|
return
|
|
685
731
|
payload = result[1]
|
|
686
732
|
if payload.get("kind") == "hint":
|
|
687
733
|
return
|
|
688
|
-
r = self.wb.set_setting(payload["key"]
|
|
734
|
+
r = self.wb.set_setting(payload["key"]) # bare value toggles booleans
|
|
689
735
|
for cls, text in r.messages:
|
|
690
736
|
self.state.say(cls, text)
|
|
691
737
|
if r.changed:
|
|
692
738
|
self._refresh_meta()
|
|
693
739
|
self._refresh_chrome()
|
|
740
|
+
self._sync_feed()
|
|
694
741
|
|
|
695
742
|
def _sessions_picked(self, result) -> None:
|
|
696
743
|
if not result:
|
|
@@ -153,6 +153,7 @@ class TuiState:
|
|
|
153
153
|
self.context_tokens = None
|
|
154
154
|
self.context_window = None
|
|
155
155
|
self.context_percent = None
|
|
156
|
+
self.reasoning_effort: str | None = None
|
|
156
157
|
self.tools: list[dict] = []
|
|
157
158
|
self.feed: list[tuple[str, str]] = []
|
|
158
159
|
self.streaming = ""
|
|
@@ -566,6 +567,8 @@ def _sidebar_lines(state: TuiState) -> list[tuple[str, str]]:
|
|
|
566
567
|
lines.append(("dim", "◆ 模型"))
|
|
567
568
|
label = f"{state.profile} · {state.model}" if state.profile else state.model
|
|
568
569
|
lines.append(("", truncate(label, 30)))
|
|
570
|
+
if state.reasoning_effort:
|
|
571
|
+
lines.append(("dim", f"推理 {state.reasoning_effort} · F6 切换"))
|
|
569
572
|
if state.context_window:
|
|
570
573
|
lines.append(("dim", f"窗口 {state.context_window:,} · F4 切换"))
|
|
571
574
|
else:
|
|
@@ -727,6 +730,26 @@ def models_overlay_items(
|
|
|
727
730
|
return items
|
|
728
731
|
|
|
729
732
|
|
|
733
|
+
def reasoning_overlay_items(current: str | None,
|
|
734
|
+
levels: tuple[str, ...]) -> list[dict]:
|
|
735
|
+
"""Items for the /reasoning picker: one selectable row per level."""
|
|
736
|
+
cur = current or "off"
|
|
737
|
+
items: list[dict] = []
|
|
738
|
+
for level in levels:
|
|
739
|
+
active = level == cur
|
|
740
|
+
label = {"off": "关闭(不发送该字段)"}.get(level, level)
|
|
741
|
+
items.append({
|
|
742
|
+
"kind": "item",
|
|
743
|
+
"label": f"{'●' if active else ' '} {label}",
|
|
744
|
+
"level": level,
|
|
745
|
+
"active": active,
|
|
746
|
+
})
|
|
747
|
+
items.append({"kind": "hint",
|
|
748
|
+
"label": "Enter 应用 · s 存为档案默认 · Esc 关闭"
|
|
749
|
+
"(个别模型支持其它值,可用 /reasoning 值 直达)"})
|
|
750
|
+
return items
|
|
751
|
+
|
|
752
|
+
|
|
730
753
|
def settings_overlay_items(setting_rows: list[dict]) -> list[dict]:
|
|
731
754
|
"""Items for the /set picker: booleans are selectable (Enter toggles),
|
|
732
755
|
numerics render as hints — a value cannot be picked from a list."""
|
|
@@ -743,8 +766,9 @@ def settings_overlay_items(setting_rows: list[dict]) -> list[dict]:
|
|
|
743
766
|
"active": bool(value),
|
|
744
767
|
})
|
|
745
768
|
else:
|
|
769
|
+
shown = "off" if value is None else value
|
|
746
770
|
items.append({"kind": "hint",
|
|
747
|
-
"label": f" {row['key']:<10} {
|
|
771
|
+
"label": f" {row['key']:<10} {shown!s:<6}{row['label']}"
|
|
748
772
|
f"(/set {row['key']} 值)"})
|
|
749
773
|
items.append({"kind": "hint",
|
|
750
774
|
"label": "Enter 切换开关 · 数值项用 /set 名称 值 · Esc 关闭"})
|
|
@@ -812,6 +836,10 @@ class SlashCompleter(Completer):
|
|
|
812
836
|
words = self.state.profile_names
|
|
813
837
|
elif command == "resume":
|
|
814
838
|
words = [f"#{row['id']}" for row in self.state.sessions]
|
|
839
|
+
elif command == "reasoning":
|
|
840
|
+
from .workbench import REASONING_LEVELS
|
|
841
|
+
|
|
842
|
+
words = list(REASONING_LEVELS)
|
|
815
843
|
elif command == "set":
|
|
816
844
|
from .workbench import _SETTING_DEFS
|
|
817
845
|
|
|
@@ -939,6 +967,7 @@ def build_app(
|
|
|
939
967
|
kb.add("f3")(lambda event: on_line("/sessions"))
|
|
940
968
|
kb.add("f4")(lambda event: on_line("/model"))
|
|
941
969
|
kb.add("f5")(lambda event: on_line("/set"))
|
|
970
|
+
kb.add("f6")(lambda event: on_line("/reasoning"))
|
|
942
971
|
|
|
943
972
|
@kb.add("escape", filter=overlay_open, eager=True)
|
|
944
973
|
@kb.add("q", filter=overlay_open, eager=True)
|
|
@@ -1049,9 +1078,10 @@ def build_app(
|
|
|
1049
1078
|
elif mode == "run":
|
|
1050
1079
|
hint = " q 退出 · F2 侧栏 " if not state.running else " Ctrl+C 取消 · PgUp/PgDn 滚动 "
|
|
1051
1080
|
elif state.running:
|
|
1052
|
-
hint = " Ctrl+C 取消本轮 · F3 会话 · F4 模型 ·
|
|
1081
|
+
hint = " Ctrl+C 取消本轮 · F3 会话 · F4 模型 · F6 推理 "
|
|
1053
1082
|
else:
|
|
1054
|
-
hint = " Enter 发送 · F2 侧栏 · F3 会话 · F4 模型
|
|
1083
|
+
hint = (" Enter 发送 · F2 侧栏 · F3 会话 · F4 模型"
|
|
1084
|
+
" · F5 设置 · F6 推理 · /help 命令 ")
|
|
1055
1085
|
return FormattedText(compose_footer(state, cols, hint))
|
|
1056
1086
|
|
|
1057
1087
|
def _prompt_text():
|
|
@@ -1167,6 +1197,7 @@ async def run_screen(cfg, task, mode, args=None):
|
|
|
1167
1197
|
def _refresh_meta(st):
|
|
1168
1198
|
st.model = cfg.model or "(scripted)"
|
|
1169
1199
|
st.profile = cfg.profile or ""
|
|
1200
|
+
st.reasoning_effort = cfg.reasoning_effort
|
|
1170
1201
|
if wb.current is not None:
|
|
1171
1202
|
st.session_id = wb.current["id"]
|
|
1172
1203
|
st.session_title = wb.current.get("title") or ""
|
|
@@ -1263,6 +1294,14 @@ async def run_screen(cfg, task, mode, args=None):
|
|
|
1263
1294
|
"set", "运行设置",
|
|
1264
1295
|
settings_overlay_items(wb.settings_rows()),
|
|
1265
1296
|
)
|
|
1297
|
+
elif name == "reasoning":
|
|
1298
|
+
from .workbench import REASONING_LEVELS
|
|
1299
|
+
|
|
1300
|
+
state.open_overlay(
|
|
1301
|
+
"reasoning", "推理强度",
|
|
1302
|
+
reasoning_overlay_items(cfg.reasoning_effort,
|
|
1303
|
+
REASONING_LEVELS),
|
|
1304
|
+
)
|
|
1266
1305
|
|
|
1267
1306
|
def _after_switch():
|
|
1268
1307
|
cid = _current_cid()
|
|
@@ -1284,6 +1323,9 @@ async def run_screen(cfg, task, mode, args=None):
|
|
|
1284
1323
|
elif name == "set":
|
|
1285
1324
|
# Enter on a boolean row toggles it (same call /set 名称 makes)
|
|
1286
1325
|
_say_result(wb.set_setting(item["key"], "toggle"))
|
|
1326
|
+
elif name == "reasoning":
|
|
1327
|
+
_say_result(wb.set_reasoning(item["level"]))
|
|
1328
|
+
_refresh_meta(state)
|
|
1287
1329
|
|
|
1288
1330
|
def on_overlay_key(name, key):
|
|
1289
1331
|
if name == "sessions":
|
|
@@ -1316,6 +1358,13 @@ async def run_screen(cfg, task, mode, args=None):
|
|
|
1316
1358
|
_say_result(wb.set_profile(item["profile"]))
|
|
1317
1359
|
_say_result(wb.set_model(item["model"], save=True))
|
|
1318
1360
|
_refresh_meta(state)
|
|
1361
|
+
elif name == "reasoning":
|
|
1362
|
+
if key == "s":
|
|
1363
|
+
item = state.overlay_current()
|
|
1364
|
+
state.close_overlay()
|
|
1365
|
+
if item:
|
|
1366
|
+
_say_result(wb.set_reasoning(item["level"], save=True))
|
|
1367
|
+
_refresh_meta(state)
|
|
1319
1368
|
|
|
1320
1369
|
# -- input ----------------------------------------------------------------
|
|
1321
1370
|
|
|
@@ -1342,7 +1391,7 @@ async def run_screen(cfg, task, mode, args=None):
|
|
|
1342
1391
|
return
|
|
1343
1392
|
if r.awaitable is not None:
|
|
1344
1393
|
asyncio.create_task(r.awaitable())
|
|
1345
|
-
if r.overlay in ("sessions", "model", "set"):
|
|
1394
|
+
if r.overlay in ("sessions", "model", "set", "reasoning"):
|
|
1346
1395
|
_open_picker(r.overlay)
|
|
1347
1396
|
if r.overlay == "rebuild":
|
|
1348
1397
|
_after_switch()
|
|
@@ -46,12 +46,17 @@ _SETTING_DEFS: list[tuple[str, str, str, str]] = [
|
|
|
46
46
|
("max-steps", "max_steps", "工具循环步数上限", "int"),
|
|
47
47
|
("timeout", "timeout", "单次模型调用超时(秒)", "float"),
|
|
48
48
|
("attempts", "attempts", "模型调用重试次数", "int"),
|
|
49
|
+
("reasoning-effort", "reasoning_effort",
|
|
50
|
+
"推理强度(off/minimal/low/medium/high,原样透传)", "enum"),
|
|
49
51
|
]
|
|
50
52
|
# Settings whose change alters the next turn's tool registry (vs. sampling
|
|
51
53
|
# or rendering knobs): flipping them invalidates the /tools cache.
|
|
52
54
|
_TOOL_AFFECTING = {"shell", "code", "vision", "download"}
|
|
53
55
|
_TRUTHY = {"on", "true", "1", "开"}
|
|
54
56
|
_FALSY = {"off", "false", "0", "关"}
|
|
57
|
+
# Reasoning levels offered by /reasoning; any other typed token passes
|
|
58
|
+
# through verbatim (rare per-model values like "none" stay reachable).
|
|
59
|
+
REASONING_LEVELS = ("off", "minimal", "low", "medium", "high")
|
|
55
60
|
|
|
56
61
|
|
|
57
62
|
class Workbench:
|
|
@@ -258,6 +263,41 @@ class Workbench:
|
|
|
258
263
|
self.sessions.set_meta(self.current["id"], {"model": name})
|
|
259
264
|
return result
|
|
260
265
|
|
|
266
|
+
def set_reasoning(self, arg: str, *, save: bool = False) -> ActionResult:
|
|
267
|
+
"""``/reasoning`` — view / set the reasoning-effort knob.
|
|
268
|
+
|
|
269
|
+
``arg`` empty → listing + picker overlay; otherwise a level (or any
|
|
270
|
+
verbatim token); ``off`` clears. ``--save`` persists to the profile.
|
|
271
|
+
"""
|
|
272
|
+
result = ActionResult()
|
|
273
|
+
arg = arg.strip()
|
|
274
|
+
if not arg:
|
|
275
|
+
current = self.cfg.reasoning_effort or "off"
|
|
276
|
+
result.say("dim", f"当前推理强度:{current}")
|
|
277
|
+
for i, level in enumerate(REASONING_LEVELS, 1):
|
|
278
|
+
mark = "●" if level == current else " "
|
|
279
|
+
result.say("dim", f" {mark} {i}. {level}")
|
|
280
|
+
result.say("dim", "(/reasoning 级别 或 /reasoning 序号;off 表示不发送"
|
|
281
|
+
"该字段;--save 存为档案默认)")
|
|
282
|
+
result.overlay = "reasoning"
|
|
283
|
+
return result
|
|
284
|
+
if arg.isdigit():
|
|
285
|
+
idx = int(arg) - 1
|
|
286
|
+
if not 0 <= idx < len(REASONING_LEVELS):
|
|
287
|
+
result.say("err", f"序号超出范围(1–{len(REASONING_LEVELS)})")
|
|
288
|
+
return result
|
|
289
|
+
arg = REASONING_LEVELS[idx]
|
|
290
|
+
r = self.set_setting("reasoning-effort", arg)
|
|
291
|
+
result.messages.extend(r.messages)
|
|
292
|
+
if r.messages and r.messages[0][0] == "ok" and save:
|
|
293
|
+
if self.cfg.profile:
|
|
294
|
+
self.profiles.set_reasoning_effort(
|
|
295
|
+
self.cfg.profile, self.cfg.reasoning_effort)
|
|
296
|
+
result.say("ok", f"(已存为档案 {self.cfg.profile} 默认)")
|
|
297
|
+
else:
|
|
298
|
+
result.say("dim", "(没有已保存档案,--save 未生效)")
|
|
299
|
+
return result
|
|
300
|
+
|
|
261
301
|
def set_profile(self, name: str) -> ActionResult:
|
|
262
302
|
result = ActionResult(changed=True)
|
|
263
303
|
try:
|
|
@@ -462,6 +502,17 @@ class Workbench:
|
|
|
462
502
|
else:
|
|
463
503
|
result.say("err", f"{ukey} 是开关:on / off(不带值则为切换)")
|
|
464
504
|
return result
|
|
505
|
+
elif kind == "enum":
|
|
506
|
+
token = value.strip()
|
|
507
|
+
if not token:
|
|
508
|
+
known = "、".join(REASONING_LEVELS)
|
|
509
|
+
result.say("err", f"用法:/reasoning 级别({known};当前 "
|
|
510
|
+
f"{current or 'off'})")
|
|
511
|
+
return result
|
|
512
|
+
# "off" clears the knob (nothing sent); other tokens pass
|
|
513
|
+
# through verbatim — which values the model accepts is the
|
|
514
|
+
# endpoint's call (400 diagnostics catch mistakes).
|
|
515
|
+
new = None if token.lower() == "off" else token
|
|
465
516
|
else:
|
|
466
517
|
if not value.strip():
|
|
467
518
|
result.say("err", f"用法:/set {ukey} 值(当前 {current})")
|
|
@@ -475,14 +526,16 @@ class Workbench:
|
|
|
475
526
|
result.say("err", f"{ukey} 必须为正数")
|
|
476
527
|
return result
|
|
477
528
|
if new == current:
|
|
478
|
-
result.say("dim", f"{label}:已是 {new}")
|
|
529
|
+
result.say("dim", f"{label}:已是 {new if new is not None else 'off'}")
|
|
479
530
|
return result
|
|
480
531
|
setattr(self.cfg, attr, new)
|
|
481
532
|
if ukey in _TOOL_AFFECTING:
|
|
482
533
|
self._tool_names = None # /tools must re-derive the registry
|
|
483
534
|
result.changed = True
|
|
484
|
-
shown = "on" if new is True else "off"
|
|
485
|
-
|
|
535
|
+
shown = "on" if new is True else "off" \
|
|
536
|
+
if new is False or new is None else new
|
|
537
|
+
was = "on" if current is True else "off" \
|
|
538
|
+
if current is False or current is None else current
|
|
486
539
|
result.say("ok", f"{ukey}:{was} → {shown},下一轮生效")
|
|
487
540
|
if ukey == "shell" and new is True:
|
|
488
541
|
result.say("warn", "run_command 以当前用户权限执行、非沙箱、结果不可撤销")
|
|
@@ -581,15 +634,23 @@ class Workbench:
|
|
|
581
634
|
if cmd == "set":
|
|
582
635
|
if not arg:
|
|
583
636
|
for row in self.settings_rows():
|
|
584
|
-
|
|
585
|
-
|
|
637
|
+
value = row["value"]
|
|
638
|
+
shown = "on" if value is True else "off" \
|
|
639
|
+
if value is False or value is None else value
|
|
640
|
+
hint = "" if row["kind"] != "enum" \
|
|
641
|
+
else "(/reasoning 或 F6 调整)"
|
|
586
642
|
result.say("dim",
|
|
587
|
-
f" {row['key']:<10} {str(shown):<6}
|
|
643
|
+
f" {row['key']:<10} {str(shown):<6} "
|
|
644
|
+
f"{row['label']}{hint}")
|
|
588
645
|
result.say("dim", "(/set 名称 on|off 或 /set 序号;数值项 /set 名称 值)")
|
|
589
646
|
result.overlay = "set"
|
|
590
647
|
return result
|
|
591
648
|
key, _, value = arg.partition(" ")
|
|
592
649
|
return self.set_setting(key, value)
|
|
650
|
+
if cmd == "reasoning":
|
|
651
|
+
save = "--save" in arg
|
|
652
|
+
level = arg.replace("--save", "").strip()
|
|
653
|
+
return self.set_reasoning(level, save=save)
|
|
593
654
|
if cmd == "sidebar":
|
|
594
655
|
result.toggle_sidebar = True
|
|
595
656
|
return result
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lithe-cli
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.4
|
|
4
4
|
Summary: Command-line interface for the lithe agent kernel: chat, one-shot runs, undo, and run inspection.
|
|
5
5
|
License: MIT License
|
|
6
6
|
|
|
@@ -39,7 +39,7 @@ Classifier: Typing :: Typed
|
|
|
39
39
|
Requires-Python: >=3.10
|
|
40
40
|
Description-Content-Type: text/markdown
|
|
41
41
|
License-File: LICENSE
|
|
42
|
-
Requires-Dist: lithe>=0.9.
|
|
42
|
+
Requires-Dist: lithe>=0.9.18
|
|
43
43
|
Requires-Dist: prompt-toolkit>=3.0.38
|
|
44
44
|
Requires-Dist: textual>=1.0
|
|
45
45
|
Provides-Extra: dev
|
|
@@ -222,6 +222,14 @@ turning `shell` on restates its trust warning. `/tools` re-derives the
|
|
|
222
222
|
registry after a capability flip, so the listing always matches what the
|
|
223
223
|
next turn will see.
|
|
224
224
|
|
|
225
|
+
**Reasoning intensity**: `/reasoning` (or `F6`) picks a level —
|
|
226
|
+
`off / minimal / low / medium / high`, or any value your model accepts
|
|
227
|
+
(`none` on some) typed directly; `--save` persists it to the profile. The
|
|
228
|
+
kernel maps it per protocol (`reasoning_effort` on chat-completions,
|
|
229
|
+
`reasoning.effort` on Responses) and combines it with
|
|
230
|
+
`extra_body["reasoning"]` siblings such as OpenRouter's
|
|
231
|
+
`max_tokens`/`exclude`. The sidebar shows the active level when set.
|
|
232
|
+
|
|
225
233
|
### Extra capabilities
|
|
226
234
|
|
|
227
235
|
The kernel ships these as bundles; the CLI grants them per flag:
|
|
@@ -9,7 +9,7 @@ description = "Command-line interface for the lithe agent kernel: chat, one-shot
|
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { file = "LICENSE" }
|
|
11
11
|
requires-python = ">=3.10"
|
|
12
|
-
dependencies = ["lithe>=0.9.
|
|
12
|
+
dependencies = ["lithe>=0.9.18", "prompt-toolkit>=3.0.38", "textual>=1.0"]
|
|
13
13
|
keywords = ["agent", "llm", "react", "cli", "tool-calling"]
|
|
14
14
|
classifiers = [
|
|
15
15
|
"Development Status :: 4 - Beta",
|
|
@@ -293,3 +293,24 @@ def test_endpoint_roundtrips_provider_field(tmp_path, monkeypatch):
|
|
|
293
293
|
# 无 provider 的档案不受影响
|
|
294
294
|
store.upsert("plain", "https://p.example", "sk", "m")
|
|
295
295
|
assert "provider" not in fresh.endpoint("plain")
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
def test_reasoning_effort_profile_roundtrip(tmp_path, monkeypatch):
|
|
299
|
+
from lithe_cli.config import load_config
|
|
300
|
+
|
|
301
|
+
monkeypatch.setenv("LITHE_HOME", str(tmp_path / "home"))
|
|
302
|
+
for var in ("LITHE_API_KEY", "LITHE_BASE_URL", "LITHE_MODEL",
|
|
303
|
+
"LITHE_PROFILE", "LITHE_PROVIDER"):
|
|
304
|
+
monkeypatch.delenv(var, raising=False)
|
|
305
|
+
store = ProfileStore()
|
|
306
|
+
store.upsert("zai", "", "sk", "glm-4.6", provider="zai")
|
|
307
|
+
store.set_reasoning_effort("zai", "high")
|
|
308
|
+
|
|
309
|
+
cfg = load_config(_PresetArgs())
|
|
310
|
+
assert cfg.reasoning_effort == "high", "档案字段经 load_config 进入 cfg"
|
|
311
|
+
|
|
312
|
+
# "off" 归一化为不发(None),并存回时清除字段
|
|
313
|
+
store.set_reasoning_effort("zai", "off")
|
|
314
|
+
cfg = load_config(_PresetArgs())
|
|
315
|
+
assert cfg.reasoning_effort is None
|
|
316
|
+
assert "reasoning_effort" not in store.endpoint("zai")
|
|
@@ -10,7 +10,13 @@ from conftest import _tc, make_config
|
|
|
10
10
|
|
|
11
11
|
textual = pytest.importorskip("textual")
|
|
12
12
|
|
|
13
|
-
from lithe_cli.ttui import
|
|
13
|
+
from lithe_cli.ttui import ( # noqa: E402
|
|
14
|
+
LitheApp,
|
|
15
|
+
PickerModal,
|
|
16
|
+
footer_text,
|
|
17
|
+
header_text,
|
|
18
|
+
sidebar_markup,
|
|
19
|
+
)
|
|
14
20
|
from lithe_cli.tui import TuiState # noqa: E402
|
|
15
21
|
|
|
16
22
|
WRITE_THEN_ANSWER = [
|
|
@@ -306,3 +312,45 @@ def test_resolve_ui_defaults_to_textual(monkeypatch):
|
|
|
306
312
|
assert _resolve_ui(args) == "prompt" # flag beats env
|
|
307
313
|
monkeypatch.setenv("LITHE_UI", "garbage")
|
|
308
314
|
assert _resolve_ui(Args()) == "textual" # unknown values fall back
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
def test_f6_opens_reasoning_picker_and_applies(tmp_path):
|
|
318
|
+
"""Regression: F6 crashed with AttributeError (wb.REASONING_LEVELS)."""
|
|
319
|
+
|
|
320
|
+
async def scenario():
|
|
321
|
+
app = _app(tmp_path, [])
|
|
322
|
+
async with app.run_test(size=(100, 30)) as pilot:
|
|
323
|
+
await pilot.press("f6")
|
|
324
|
+
await pilot.pause()
|
|
325
|
+
assert isinstance(app.screen, PickerModal)
|
|
326
|
+
levels = [p["level"] for p, _ in app.screen.items]
|
|
327
|
+
assert levels == ["off", "minimal", "low", "medium", "high"]
|
|
328
|
+
for _ in range(4): # off -> high
|
|
329
|
+
await pilot.press("down")
|
|
330
|
+
await pilot.press("enter")
|
|
331
|
+
await pilot.pause()
|
|
332
|
+
assert app.cfg.reasoning_effort == "high"
|
|
333
|
+
|
|
334
|
+
asyncio.run(scenario())
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
def test_f5_settings_picker_toggles_bool(tmp_path):
|
|
338
|
+
"""Regression: F5 crashed rendering the reasoning-effort row (None
|
|
339
|
+
value), and Enter on a bool row sent the literal token 'toggle',
|
|
340
|
+
which set_setting rejects — every toggle errored with 是开关."""
|
|
341
|
+
|
|
342
|
+
async def scenario():
|
|
343
|
+
app = _app(tmp_path, [])
|
|
344
|
+
async with app.run_test(size=(100, 30)) as pilot:
|
|
345
|
+
await pilot.press("f5")
|
|
346
|
+
await pilot.pause()
|
|
347
|
+
assert isinstance(app.screen, PickerModal)
|
|
348
|
+
keys = [p.get("key") for p, _ in app.screen.items]
|
|
349
|
+
assert keys[0] == "shell" # first bool row
|
|
350
|
+
assert app.cfg.shell is False
|
|
351
|
+
await pilot.press("enter") # toggle shell on
|
|
352
|
+
await pilot.pause()
|
|
353
|
+
assert app.cfg.shell is True
|
|
354
|
+
assert "shell:off → on" in _conv_text(app)
|
|
355
|
+
|
|
356
|
+
asyncio.run(scenario())
|
|
@@ -122,6 +122,21 @@ def test_settings_overlay_items_toggles_and_hints():
|
|
|
122
122
|
assert "Enter" in items[-1]["label"]
|
|
123
123
|
|
|
124
124
|
|
|
125
|
+
def test_reasoning_overlay_items_marks_current():
|
|
126
|
+
from lithe_cli.tui import reasoning_overlay_items
|
|
127
|
+
from lithe_cli.workbench import REASONING_LEVELS
|
|
128
|
+
|
|
129
|
+
items = reasoning_overlay_items("high", REASONING_LEVELS)
|
|
130
|
+
selectable = [i for i in items if i["kind"] == "item"]
|
|
131
|
+
assert [i["level"] for i in selectable] == list(REASONING_LEVELS)
|
|
132
|
+
active = [i for i in selectable if i.get("active")]
|
|
133
|
+
assert len(active) == 1 and active[0]["level"] == "high"
|
|
134
|
+
# None(未设置)时高亮 off
|
|
135
|
+
items = reasoning_overlay_items(None, REASONING_LEVELS)
|
|
136
|
+
assert [i["level"] for i in items if i.get("active")] == ["off"]
|
|
137
|
+
assert "s 存为档案默认" in items[-1]["label"]
|
|
138
|
+
|
|
139
|
+
|
|
125
140
|
def test_picker_rows_fit_and_highlight_cursor():
|
|
126
141
|
state = TuiState("m", "/ws", 5)
|
|
127
142
|
items = [{"kind": "item", "label": f"选项 {i}"} for i in range(20)]
|
|
@@ -336,6 +336,69 @@ def test_set_tools_cache_reflected_in_next_tools_listing(tmp_path):
|
|
|
336
336
|
assert "run_command" in r.messages[0][1]
|
|
337
337
|
|
|
338
338
|
|
|
339
|
+
# --- /reasoning: in-session reasoning effort -------------------------------------
|
|
340
|
+
|
|
341
|
+
def test_reasoning_bare_lists_levels_and_opens_picker(tmp_path):
|
|
342
|
+
wb = _wb(tmp_path, [])
|
|
343
|
+
r = wb.dispatch("/reasoning")
|
|
344
|
+
text = "".join(t for _, t in r.messages)
|
|
345
|
+
assert "当前推理强度:off" in text
|
|
346
|
+
for level in ("off", "minimal", "low", "medium", "high"):
|
|
347
|
+
assert level in text
|
|
348
|
+
assert r.overlay == "reasoning"
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
def test_reasoning_set_off_and_verbatim(tmp_path):
|
|
352
|
+
wb = _wb(tmp_path, [])
|
|
353
|
+
r = wb.dispatch("/reasoning high")
|
|
354
|
+
assert wb.cfg.reasoning_effort == "high"
|
|
355
|
+
assert r.messages[0][0] == "ok" and "下一轮生效" in r.messages[0][1]
|
|
356
|
+
|
|
357
|
+
r = wb.dispatch("/reasoning off")
|
|
358
|
+
assert wb.cfg.reasoning_effort is None
|
|
359
|
+
assert "off" in r.messages[0][1]
|
|
360
|
+
|
|
361
|
+
# 不在档位里的值原样透传(个别模型的 none 等)
|
|
362
|
+
wb.dispatch("/reasoning none")
|
|
363
|
+
assert wb.cfg.reasoning_effort == "none"
|
|
364
|
+
|
|
365
|
+
# 序号选择:2 → minimal
|
|
366
|
+
wb.dispatch("/reasoning off")
|
|
367
|
+
wb.dispatch("/reasoning 2")
|
|
368
|
+
assert wb.cfg.reasoning_effort == "minimal"
|
|
369
|
+
assert wb.dispatch("/reasoning 99").messages[0][0] == "err"
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
def test_reasoning_save_persists_to_profile(tmp_path, monkeypatch):
|
|
373
|
+
monkeypatch.setenv("LITHE_HOME", str(tmp_path / "home"))
|
|
374
|
+
wb = _wb(tmp_path, [])
|
|
375
|
+
wb.profiles.upsert("zai", "", "sk", "glm-4.6", provider="zai")
|
|
376
|
+
wb.cfg.profile = "zai"
|
|
377
|
+
wb.dispatch("/reasoning high --save")
|
|
378
|
+
assert wb.profiles.endpoint("zai")["reasoning_effort"] == "high"
|
|
379
|
+
# off + --save 清除档案字段
|
|
380
|
+
wb.dispatch("/reasoning off --save")
|
|
381
|
+
assert "reasoning_effort" not in wb.profiles.endpoint("zai")
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
def test_reasoning_effort_reaches_llm_config(tmp_path):
|
|
385
|
+
from lithe_cli.agent import build_llm
|
|
386
|
+
|
|
387
|
+
wb = _wb(tmp_path, [])
|
|
388
|
+
wb.dispatch("/reasoning high")
|
|
389
|
+
llm = build_llm(wb.cfg)
|
|
390
|
+
assert llm.reasoning_effort == "high"
|
|
391
|
+
wb.dispatch("/reasoning off")
|
|
392
|
+
assert build_llm(wb.cfg).reasoning_effort is None
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
def test_set_listing_includes_reasoning_hint(tmp_path):
|
|
396
|
+
wb = _wb(tmp_path, [])
|
|
397
|
+
r = wb.dispatch("/set")
|
|
398
|
+
text = "".join(t for _, t in r.messages)
|
|
399
|
+
assert "reasoning-effort" in text and "/reasoning" in text
|
|
400
|
+
|
|
401
|
+
|
|
339
402
|
def test_undo_targets_last_session_run(tmp_path):
|
|
340
403
|
wb = _wb(tmp_path, WRITE_THEN_ANSWER + [{"content": "完成"}])
|
|
341
404
|
wb.open()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|