Skip to content

feat(agent,desktop,mobile,tui,cli): unify thinking levels on thinkingLevels - #1382

Merged
ace331 merged 9 commits into
mainfrom
feat/thinking-levels
Oct 27, 2026
Merged

ace331 merged 9 commits into
mainfrom
feat/thinking-levels

Conversation

@ace331

@ace331 ace331 commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

背景

当前思考强度由五套并行概念决定:thinkingLevels(UI)、compat.reasoningEffortValues(wire 词表)、thinkingLevelMap(逐档映射)、reasoning(能力开关)、thinkingRequired(关不掉思考)。客户端还要做“就近吸附”,服务端/内置目录也要各自维护词表,容易出现“界面显示的档位不是实际发送的档位”。

本 PR 统一为单一配置:thinkingLevels 就是模型接受的 wire 值列表。

契约

  • thinkingLevels 的每一项都是 wire 值,原样发送给 provider。
  • default 隐式存在、永远排第一、不落盘;含义是不发送任何 thinking/effort 参数,由服务端默认值决定。
  • off 表示显式关闭(按协议发 disable 写法)。
  • 未配置(缺失或空数组)→ 只有 default。
  • 档位按固定展示顺序:off → minimal → low → medium → high → xhigh → max;未知 wire 值排在已知值之后并保持声明顺序,不再按配置书写顺序显示。
  • 存量档位不在模型列表时收敛为 default(不再按深度就近吸附)。
  • reasoning 字段保留(旧客户端/旧配置兼容),但运行期不再参与任何决策。

删除:compat.reasoningEffortValues、thinkingLevelMap、supportsReasoningEffort、thinkingRequired、resolve_effort 收敛逻辑、doubao/kimi/deepseek 的 tokenizer 档位启发式。

主要改动

  • proto/rpc:ProviderModel 增加 thinking_levels + replace_thinking_levels presence 位(老客户端保存 provider 不会清空已有列表);list_models 的 thinkingLevels 恒非空且含 default。
  • agent:新档位语义、固定顺序归一化、Anthropic manual budget 扩展(max/未知值)、标题生成改用 default、provider upsert 写入/保留语义。
  • 内置目录:2406 个 reasoning 模型声明 ["minimal","low","medium","high"](历史实际发送值),删除 tlm_json;生成器新增规则与离线回填模式。
  • desktop/host:Composer、任务、Vibe、远程会话都只渲染 agent 下发的列表;自定义模型编辑器把「Supports thinking」换成档位多选(off…max,default 隐式),reasoning 隐藏 round-trip。
  • mobile/remote-protocol:同上;老 host 缺失字段时回退旧六档 + medium,绝不向旧端发送 default。
  • TUI/CLI/channels:model picker 滑杆走当前模型列表、--thinking default|max、models 输出声明档位、/effort 接受 default/max 并回显实际生效值。

依赖与发布顺序

  • 必须先合并/部署服务端 PR:futuregene/future-server#18(/v1/models 返回 thinking_levels)。
  • 旧 agent 会忽略新字段;新 agent 连旧服务端时 Future 模型暂时只剩「默认」,模型选择器打开会触发目录后台刷新恢复。
  • 破坏性变更:未声明 thinkingLevels 的自定义模型将只剩「默认」,需要在 Providers 页重新勾选;旧 thinkingLevelMap/reasoningEffortValues 配置被忽略。

验证

  • agent:cargo test -p future-agent --lib 2502 passed(13 个失败为沙箱禁止 sandbox-exec 的既有环境问题);集成测试(cli_smoke/service_startup/http_client/sqlite/session_load/compaction)全通过;clippy -D warnings clean。
  • 跨 crate:cargo check --workspace --exclude futureos --all-targets Finished。
  • host:60 passed,fmt/clippy clean。
  • desktop:eslint + tsc clean;vitest 382 files / 5301 tests passed。
  • mobile:typecheck/lint clean;jest 150 suites / 2895 tests passed。
  • remote-protocol:typecheck/vitest(62)/eslint clean。
  • TUI:1297 passed;19 个失败全部是沙箱禁止 PTY(openpty),terminal 模块未改动。
  • CLI:库/单元测试全过;2 个 config-wizard 集成测试因 PTY 被沙箱拒绝。
  • channels:全绿。
  • 端到端(隔离 HOME + 新端口):自定义模型声明 ["low","high"] → future models --json 返回 ["default","low","high"];未声明 → ["default"]。
  • proto:REGENERATE_PROTO=1 生成物与 proto 一致。

环境说明:本机沙箱无法写 ~/.cargo/~/.expo、禁止 PTY 与 sandbox-exec,且仓库钉的 Rust 1.99.1 未安装(本地用 1.97.0 验证);futureos(Tauri crate)因无法解包依赖未在本机编译,desktop/src-tauri 本次未改动。

- thinkingLevels is now the list of wire values the model accepts; the implicit
  default level means no thinking parameter is sent, off means explicit disable.
- remove compat.reasoningEffortValues, thinkingLevelMap, supportsReasoningEffort,
  thinkingRequired and the resolve_effort snapping logic; tokenizer heuristics no
  longer rewrite level values.
- reasoning stays as legacy metadata with no runtime behavior.
- new sessions start at default; stored levels not offered by a model clamp to
  default; Anthropic manual budgets extend to max/unknown values.
- catalogue thinking levels come from the Future platform (next commit on the
  server side) and from the generated built-in catalog; the generator declares
  the standard wire set for reasoning models and drops tlm_json.
- ProviderModel carries thinking_levels behind a replace_thinking_levels
  presence bit so older clients preserve a stored list instead of clearing it.
- the composer, tasks, Vibe and remote conversation pickers render exactly the
  levels the agent sends (default first, arbitrary wire values included) and
  disable only when the model offers a single choice.
- custom-model editor replaces the Supports thinking checkbox with a per-model
  multi-select of off/minimal/low/medium/high/xhigh/max; reasoning is kept as a
  hidden round-trip value and the new proto presence bit preserves lists when an
  older client edits a provider.
- older agents (no thinkingLevels field) keep the legacy six levels and never
  receive the literal default.
…logue

The phone renders the host's declared list verbatim (raw label fallback for
wire values), starts new conversations at default, falls back to the legacy six
levels plus medium only when an older host omits the field, and lets the custom
provider editor choose per-model levels that round-trip through the upsert.
- the workbench model picker's effort slider walks the highlighted model's own
  list (launchpad starts at default); --thinking and --model id:level accept
  default and max; the models table prints declared wire values.
- provider editing round-trips thinking levels with the same presence-bit
  semantics as the desktop.
- channels accept default/max for /effort and echo the level the agent actually
  applied.
Resolve the doubao open question (the platform now declares thinking_levels)
and add the implementation/verification record for the new semantics.
The chips and the implicit Default are self-explanatory; the extra paragraph
only added noise.
The reload test sends an explicit low level on the default test model. Levels
are now validated against the model's declared list, so register a model that
offers low instead of relying on the old unconstrained behavior.
Declared order was a set, not a display sequence: a hand-written
thinkingLevels list such as `off,minimal,low,medium,xhigh,high,max` reached
the composer verbatim, so the picker put xhigh before high. Normalize into the
product scale (off → minimal → low → medium → high → xhigh → max) at load, with
unknown wire values after the known ones in their declaration order, so every
client renders the same order no matter how the configuration was written.
@ace331
ace331 merged commit 16ab56b into main Oct 27, 2026
35 checks passed
@ace331
ace331 deleted the feat/thinking-levels branch October 27, 2026 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant