fix: resolve and synchronize thinking effort - #1625
Conversation
# Conflicts: # packages/agent-core-v2/src/app/llmProtocol/errors.ts
🦋 Changeset detectedLatest commit: 6b092b8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 495d07db56
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ab12dc435e
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 02bbcbb17c
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 58d5197b73
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f4ad40473
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6ce4b2cf2f
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| this.agent.records.logRecord({ | ||
| type: 'config.update', | ||
| ...changed, | ||
| ...effectiveChanged, |
There was a problem hiding this comment.
Keep env-forced Kimi effort out of replay records
When KIMI_MODEL_THINKING_EFFORT is set, effectiveChanged contains the forced provider value, and this record path now persists that value as config.update. Live state still keeps _unforcedThinkingEffort as the user's base value, but after resume records.replay feeds the persisted record back through agent.config.update(input), so the forced value becomes the new unforced value; switching from a Kimi model to a non-Kimi model after resume can therefore carry max/the env override into the non-Kimi provider. The fresh issue here is that the forced value is now written to replay records, not just reflected in status.
Useful? React with 👍 / 👎.
| if (persist) { | ||
| try { | ||
| persisted = await persistModelSelection(host, alias, effort); | ||
| persisted = await persistModelSelection(host, effectiveAlias, effectiveEffort); |
There was a problem hiding this comment.
Persist the selected effort, not env-forced status
In an active session with KIMI_MODEL_THINKING_EFFORT set, session.getStatus() returns the provider-effective effort, including the env-only forced value. Passing effectiveEffort into persistModelSelection makes /model save that env override into config.toml when the user chooses to persist the selection, so a temporary shell override such as max becomes the permanent default even if the user selected a different supported effort. Keep using the effective value for display/state, but persist the selected/base effort with Kimi fallback applied before env forcing.
Useful? React with 👍 / 👎.
# Conflicts: # packages/agent-core-v2/src/agent/profile/profile.ts # packages/agent-core-v2/src/app/llmProtocol/providers/anthropic.ts # packages/agent-core-v2/src/app/llmProtocol/providers/openai-common.ts # packages/agent-core-v2/src/app/model/modelInstance.ts # packages/agent-core-v2/src/app/model/modelResolverService.ts # packages/agent-core-v2/src/app/model/thinking.ts # packages/agent-core-v2/test/agent/fullCompaction/fullCompaction.test.ts # packages/agent-core-v2/test/agent/profile/thinking.test.ts # packages/agent-core-v2/test/app/config/config.test.ts
* fix: preserve provider thinking effort values * fix: resolve Kimi thinking effort fallbacks * fix: use resolved Kimi effort in v2 requests * fix: align Kimi effort resolution paths * fix: synchronize forced Kimi effort state * fix: synchronize forced Kimi effort in v2 state * fix: tolerate unresolved models in v2 status
…oonshotAI#1676 MoonshotAI#1625 MoonshotAI#1746 MoonshotAI#1753 MoonshotAI#1757) Critical fixes cherry-picked from upstream v0.24.x: - fix(agent-core-v2): align rate-limit retries with v1 (MoonshotAI#1598) - fix: preserve empty reasoning across providers (MoonshotAI#1676) - fix: resolve and synchronize thinking effort (MoonshotAI#1625) - fix: align Anthropic-compatible model capabilities (MoonshotAI#1746) - fix(kap-server): close auth bypass via percent-encoded API paths (MoonshotAI#1753) - fix: preserve the crash error in diagnostic logs on unexpected exit (MoonshotAI#1757)
Related Issue
No linked issue. This PR fixes inconsistent thinking-effort handling when model capabilities differ or when a provider accepts values that Kimi models do not advertise.
Problem
Thinking effort was partially interpreted at the provider boundary. For Kimi models, an effort outside
support_effortscould be silently omitted from the request while the core state and UI still retained the stale requested value. This was especially visible after switching from a model that supports values such asultrato a model that supports onlylow,medium, andhigh.At the same time, provider-side allow-list filtering could rewrite or drop concrete effort values for non-Kimi providers before the upstream API had a chance to validate them.
What changed
onfor Kimi models that support thinking but do not expose an effort list.supportEffortsfiltering while preserving the Kimi Anthropic request shape.@moonshot-ai/kimi-code.Checklist
gen-changesetsworkflow and added the required changeset.gen-docsworkflow and updated the affected user documentation.Validation
pnpm --filter @moonshot-ai/agent-core-v2 test(236 files, 3199 tests)pnpm --filter @moonshot-ai/agent-core test(3762 passed; existing expected failures/skips unchanged)pnpm --filter @moonshot-ai/kosong test(49 files, 1191 tests)pnpm --filter @moonshot-ai/kimi-code test -- test/tui/kimi-tui-message-flow.test.ts(144 tests)pnpm --filter @moonshot-ai/agent-core-v2 lint:domain(842 files)