Repository navigation
feat(env): migrate kimi-cli model request params and auto-update toggle - #458
Conversation
Migrate still-relevant environment variables from kimi-cli: - KIMI_MODEL_TEMPERATURE / KIMI_MODEL_TOP_P: sampling params applied globally to any kimi provider (not tied to KIMI_MODEL_NAME). - KIMI_MODEL_THINKING_KEEP: Moonshot preserved-thinking passthrough (thinking.keep), injected only while Thinking is on. - KIMI_CODE_NO_AUTO_UPDATE (legacy alias KIMI_CLI_NO_AUTO_UPDATE): fully disables the update preflight. Wires env -> provider in Agent.get llm() via applyKimiEnvGenerationParams, reusing kosong's existing GenerationKwargs / thinking.keep support. KIMI_MODEL_MAX_TOKENS is intentionally untouched: it already flows through the completion-budget path.
🦋 Changeset detectedLatest commit: 675c355 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
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: e2a9c0a678
ℹ️ 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".
| const provider = applyKimiEnvGenerationParams( | ||
| this.config.provider.withThinking(this.config.thinkingLevel), | ||
| this.config.thinkingLevel, | ||
| ); |
There was a problem hiding this comment.
Apply env params to compaction requests too
This only wraps the provider used by Agent.llm, but full-history compaction builds its own provider at packages/agent-core/src/agent/compaction/full.ts:243-250 from this.agent.config.provider and then calls this.agent.generate(...) directly. In sessions that trigger compaction, KIMI_MODEL_TEMPERATURE, KIMI_MODEL_TOP_P, and KIMI_MODEL_THINKING_KEEP are therefore not applied to those Kimi requests, despite the new behavior being documented/changesetted as global for every Kimi request.
Useful? React with 👍 / 👎.
Sink KIMI_MODEL_TEMPERATURE / KIMI_MODEL_TOP_P into ConfigState.provider so every request built from config.provider — main loop and full-history compaction alike — carries them, matching kimi-cli where these live on the shared create_llm provider. thinking.keep stays in Agent.llm because it depends on the runtime thinking state (compaction runs thinking-off and correctly skips it). Splits applyKimiEnvGenerationParams into applyKimiEnvSamplingParams (applied at provider construction) and applyKimiEnvThinkingKeep (applied in Agent.llm). Addresses PR review feedback about compaction requests bypassing the wrapped provider.
Resolve overlap with #464 (preserve thinking during compaction): both sink provider request config from Agent.llm into ConfigState.provider. #464 sinks withThinking; this branch sinks the KIMI_MODEL_* sampling params and thinking.keep alongside it. Net effect: compaction — which now carries thinking via #464 — also carries temperature/top_p and (when thinking is on) thinking.keep. Agent.llm now simply reads config.provider.
…le (#458) * feat(env): migrate kimi-cli model request params and auto-update toggle Migrate still-relevant environment variables from kimi-cli: - KIMI_MODEL_TEMPERATURE / KIMI_MODEL_TOP_P: sampling params applied globally to any kimi provider (not tied to KIMI_MODEL_NAME). - KIMI_MODEL_THINKING_KEEP: Moonshot preserved-thinking passthrough (thinking.keep), injected only while Thinking is on. - KIMI_CODE_NO_AUTO_UPDATE (legacy alias KIMI_CLI_NO_AUTO_UPDATE): fully disables the update preflight. Wires env -> provider in Agent.get llm() via applyKimiEnvGenerationParams, reusing kosong's existing GenerationKwargs / thinking.keep support. KIMI_MODEL_MAX_TOKENS is intentionally untouched: it already flows through the completion-budget path. * fix(env): apply Kimi sampling params to compaction requests too Sink KIMI_MODEL_TEMPERATURE / KIMI_MODEL_TOP_P into ConfigState.provider so every request built from config.provider — main loop and full-history compaction alike — carries them, matching kimi-cli where these live on the shared create_llm provider. thinking.keep stays in Agent.llm because it depends on the runtime thinking state (compaction runs thinking-off and correctly skips it). Splits applyKimiEnvGenerationParams into applyKimiEnvSamplingParams (applied at provider construction) and applyKimiEnvThinkingKeep (applied in Agent.llm). Addresses PR review feedback about compaction requests bypassing the wrapped provider.
…le (MoonshotAI#458) * feat(env): migrate kimi-cli model request params and auto-update toggle Migrate still-relevant environment variables from kimi-cli: - KIMI_MODEL_TEMPERATURE / KIMI_MODEL_TOP_P: sampling params applied globally to any kimi provider (not tied to KIMI_MODEL_NAME). - KIMI_MODEL_THINKING_KEEP: Moonshot preserved-thinking passthrough (thinking.keep), injected only while Thinking is on. - KIMI_CODE_NO_AUTO_UPDATE (legacy alias KIMI_CLI_NO_AUTO_UPDATE): fully disables the update preflight. Wires env -> provider in Agent.get llm() via applyKimiEnvGenerationParams, reusing kosong's existing GenerationKwargs / thinking.keep support. KIMI_MODEL_MAX_TOKENS is intentionally untouched: it already flows through the completion-budget path. * fix(env): apply Kimi sampling params to compaction requests too Sink KIMI_MODEL_TEMPERATURE / KIMI_MODEL_TOP_P into ConfigState.provider so every request built from config.provider — main loop and full-history compaction alike — carries them, matching kimi-cli where these live on the shared create_llm provider. thinking.keep stays in Agent.llm because it depends on the runtime thinking state (compaction runs thinking-off and correctly skips it). Splits applyKimiEnvGenerationParams into applyKimiEnvSamplingParams (applied at provider construction) and applyKimiEnvThinkingKeep (applied in Agent.llm). Addresses PR review feedback about compaction requests bypassing the wrapped provider.
背景
kcode-open 是 kimi-cli 的 TS 重制版。对比两边环境变量后,把 kimi-cli 中仍有价值、但 kcode-open 缺失的变量迁移过来。
迁移的变量(全局生效,仅对 `kimi` provider)
语义对齐 kimi-cli 的 `create_llm`:对任何 kimi provider 全局生效,不依赖 `KIMI_MODEL_NAME`。
实现
关于 `KIMI_MODEL_MAX_TOKENS`(有意未改动)
它在 kcode-open 早已存在并生效——`completion-budget.ts` 已把它作为 `KIMI_MODEL_MAX_COMPLETION_TOKENS` 的 legacy alias 全链路处理。再迁移会产生重复且冲突的两套来源,故复用现有实现,不重复迁移。
不迁移(无承接点 / 已被等价承接)
`KIMI_WEB_`、`KIMI_VIS_RESTRICT_OPEN_IN`、`KIMI_CLI_PASTE_`、`KIMI_FILE_UPLOAD_WITHOUT_MESSAGE`、`KIMI_ANSI_THEME*`(功能不存在);`KIMI_CLI_GIT_BASH_PATH`→已有 `KIMI_SHELL_PATH`、`KIMI_SHARE_DIR`→已有 `KIMI_CODE_HOME`。
测试