Skip to content

feat: scope thinking effort to the current session#1933

Merged
liruifengv merged 13 commits into
mainfrom
feat/session-scoped-thinking-effort
Jul 20, 2026
Merged

feat: scope thinking effort to the current session#1933
liruifengv merged 13 commits into
mainfrom
feat/session-scoped-thinking-effort

Conversation

@liruifengv

@liruifengv liruifengv commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

None — the problem is explained below.

Problem

Thinking effort used to be persisted wholesale: any pick in the TUI or the web UI wrote the concrete effort to thinking.effort in config.toml as the global default for every future session, and the web UI additionally kept the level as a browser-wide per-model pick that leaked across sessions. Picking max once made every new session run at max forever; picking high in one session silently changed what an older session displayed and submitted.

What changed

  • Picker re-confirm is not a choice (TUI). Confirming the effort value shown when the model/effort picker opened no longer writes it to the config — only a deliberate change persists (the model itself is still saved on a switch).
  • Bounded persistence. Picking a model or thinking level persists the concrete effort only when it is below the model's highest declared level (the last entry of its support_efforts). The top tier is session-only — only the boolean thinking.enabled toggle is saved, so the most expensive level never becomes the default for every new session. A manually configured thinking.effort is still honored.
  • One-time migration. A previously persisted thinking.effort = "max" is rewritten to "high" exactly once per installation (recorded in migrations-effort.json); a max written by hand afterwards is left alone.
  • Per-session thinking in the web UI. Each session's own daemon-reported level (session status endpoint + live status events) is restored when switching sessions and is what prompts submit, including queued and side-chat prompts. The browser-local per-model pick store is removed entirely (the stale key is cleaned up on startup); new sessions start at the model's default level.
  • KIMI_MODEL_THINKING_EFFORT stays a pure runtime override and can never reach config.toml (covered by existing round-trip tests).
  • Tests updated and added in the CLI, the web UI, and both agent engines.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update. (Docs only describe the [thinking] config fields, which remain valid; the persistence policy of UI picks was not documented.)

Selecting a model or thinking mode in the TUI or web UI no longer
persists the concrete effort to the config; only the boolean thinking
toggle is saved. The web UI now restores and submits each session's own
daemon-reported level instead of a browser-wide per-model pick, whose
localStorage store is removed.
@changeset-bot

changeset-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f128c9c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 20, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@f128c9c
npx https://pkg.pr.new/@moonshot-ai/kimi-code@f128c9c

commit: f128c9c

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a358fdadc1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/kimi-web/src/composables/client/useModelProviderState.ts
Only low/medium/high/xhigh are written to the config on a pick; max and
unrecognized levels stay session-only with just the boolean toggle saved.
A one-shot migration rewrites a previously persisted thinking.effort max
to high (recorded in migrations.json, never re-run). The web UI brings
back the per-model localStorage pick as the seed for new sessions, while
a session's own daemon-reported level keeps winning for existing ones.
The session-only tier is now the last entry of the model's own
support_efforts (ordered by strength) instead of a fixed name list, so
custom provider-declared levels get the same treatment; anything below
the top persists as before, and unknown model metadata keeps the
concrete effort.
A raw single-level string left in localStorage by older versions was
migrated into a '*' fallback entry applied to every model; stale values
(typically max) could silently steer any session. Non-map content is now
discarded instead of inherited.
Thinking in the web UI is now sourced only from the daemon: a session's
own reported level wins when the model declares it, and everything else
falls back to the model's catalog default. The stale localStorage key is
cleaned up on startup.
Re-confirming the effort shown when the model/effort picker opened is not
an explicit choice: the TUI persists only the model (no effort key, or no
write at all when nothing changed), and the web skips the global config
write the same way it already did for model switches.
Only the TUI skips the effort write when the picker confirms its initial
value; the web behavior stays unchanged until the interaction is
reconsidered.
A level picked on the empty composer lived only in rawState.thinking, so
selectSession's watcher overwrote it with the catalog default and the
first prompt/skill submitted that instead of the pick. createDraftSession
now captures the draft level and seeds the new session's own entry.
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f73ca43471

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/kimi-code/src/tui/commands/provider.ts Outdated
Comment thread apps/kimi-web/src/composables/client/useWorkspaceState.ts Outdated
The provider-add default-model flow now resolves support_efforts through
effectiveModelForHost (overrides + protocol-profile inference), so a
top-tier pick on catalog models without declared efforts no longer
persists. The draft thinking level is captured before the session
creation awaits, so a concurrent session switch can no longer seed the
new session with another session's effort.
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa29064ff6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/kimi-web/src/composables/client/useModelProviderState.ts
In the cold window right after a reload or session switch, the session's
own level has not landed from /status yet; resolving straight to the
catalog default would carry the wrong level to the daemon, which writes
it into the session profile. Send, steer, side-chat and skill-activation
paths now await the fold when the session entry is missing.
@liruifengv
liruifengv merged commit 11c1683 into main Jul 20, 2026
14 checks passed
@liruifengv
liruifengv deleted the feat/session-scoped-thinking-effort branch July 20, 2026 04:57
@github-actions github-actions Bot mentioned this pull request Jul 20, 2026
7723qqq added a commit to 7723qqq/kimi-code that referenced this pull request Jul 20, 2026
Upstream changes:
- feat(cli): replace kimi server command tree with kimi web (MoonshotAI#1826)
  - Removed daemon/server lifecycle (svc/ layer for launchd/systemd/schtasks)
  - Multi-server instance registry replaces single-writer lock
  - /web TUI command uses server picker instead of daemon logic
- feat(minidb): switch agent-core-v2 query-store to ClusterDb with 16 shards (MoonshotAI#1907)
  - Multiple kimi processes can share the read model concurrently
- feat: scope thinking effort to current session (MoonshotAI#1933)
- feat: add thinking_effort to turn telemetry events (MoonshotAI#1916)
- fix(agent-core-v2): host fs stat follows symlinks, add explicit lstat (MoonshotAI#1843)
- feat(web): add cache invalidation note to model switcher (MoonshotAI#1940)
- ci: release packages (MoonshotAI#1868)

Conflicts resolved:
- 9 modify/delete conflicts: accepted upstream deletion (server/*, svc/*)
- 6 content conflicts: merged while preserving fork's i18n t() calls
  and fork-specific test suites (config edge cases)
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