Skip to content

feat(chat): per-conversation reasoning-effort selector in the composer (#641) - #2564

Merged
pancacake merged 3 commits into
HKUDS:devfrom
evan188199-tech:fix/641-reasoning-effort
Nov 15, 2026
Merged

pancacake merged 3 commits into
HKUDS:devfrom
evan188199-tech:fix/641-reasoning-effort

Conversation

@evan188199-tech

Copy link
Copy Markdown
Contributor

Summary

Adds a per-conversation reasoning-effort selector next to the model picker in the chat composer.

  • LLMSelection gains an optional, validated reasoning_effort (same vocabulary/normalization as the service layer). Old two-ID payloads stay valid; generated contracts were regenerated with the existing scripts.
  • The composer offers only levels the selected model supports (live catalog supported_reasoning_efforts, else the provider/model tables), hides the control when nothing is selectable, and persists the choice on the conversation's llm_selection.
  • Persisted overrides are re-validated against the selected model: unsupported values are cleared once options resolve, are never re-added on the fallback path, and are stripped from both the live send and resend llm_selection paths, so a stale value never reaches the provider.
  • Precedence is unchanged (conversation override → model/profile default → provider default, from feat: add per-conversation reasoning-effort override (#641) #958). The context-budget chip shows the resolved effort.

Tests

  • New tests/core/test_turn_request_llm_selection.py, plus updates to WS turn runtime and context-budget tests.
  • Web: reasoning-effort.test.ts, reasoning-effort-selector.spec.tsx, new reasoning-effort-restore.spec.ts (restore after supported levels change).
  • Locally: web typecheck and eslint pass, test:node 1354/1354, test:unit 1221/1221; focused pytest and ruff pass.

Fixes #641

HKUDS#641)

Carry the HKUDS#958 service-layer reasoning_effort override through the whole
turn contract: the core TurnRequest LLMSelection accepts the field
(validated against VALID_REASONING_EFFORTS, old two-ID payloads unchanged),
the generated web contracts are regenerated, and ChatStateAdapter's
asLLMSelection restores a legal override instead of dropping it.

The composer gains a selector beside the model picker, offering only the
levels the selected model supports (live supported_reasoning_efforts or
the provider/model tables) narrowed to the wire vocabulary, hidden when
the model has none. The choice persists on the conversation's
llm_selection, so the next send uses it without a backend restart and
other conversations are unaffected; switching models resets the override.
Precedence stays conversation override -> profile/model default ->
provider default, and the context-budget readout reports the effective
effort beside the model when one was used.
…UDS#641)

A persisted override the selected model no longer supports (e.g. a saved
xhigh after the catalog restricts the model to low/high) could reach the
provider: the selector re-listed the stale value, and the send path
forwarded the restored llm_selection.reasoning_effort unchecked.

- lib/reasoning-effort.ts: supportedReasoningEffortValues() returns the
  model's supported wire values (catalog list, else provider/model tables
  honouring declared_reasoning) without ever re-adding the stored value;
  effectiveReasoningEffort() resolves an override to null when the model
  does not support it; dropUnvalidatedReasoningEffort() strips it from an
  outgoing llm_selection — including when the option is unresolved, where
  the override is omitted (falls back to the configured default) rather
  than forwarded unvalidated.
- ReasoningEffortSelector: computeReasoningOptions uses the helper; a
  stale value is not offered and Auto renders as selected instead.
- ChatComposer: once the model options are loaded, a detected-unsupported
  persisted override is reset through the selector's onChange persist
  path; nothing is cleared while the option is still unresolved.
- ChatStateAdapter: outgoing llm_selection (live send and failed-turn
  resend) is sanitized via the last-known option catalog, which
  listLLMOptions now records (readLastKnownLLMOptions, synchronous).
- tests: helper/selector/restore-path coverage in
  reasoning-effort.test.ts, reasoning-effort-selector.spec.tsx and the
  new reasoning-effort-restore.spec.ts.
@pancacake
pancacake changed the base branch from main to dev November 13, 2026 20:42
@pancacake
pancacake merged commit 16cc590 into HKUDS:dev Nov 15, 2026
23 checks passed
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.

[Feature Request]:Add a per-conversation reasoning-effort selector to the chat composer

2 participants