fix(config): 适配 kimi-code 0.39.1——thinking keep 写字符串 off(布尔会整节作废)、存量布尔归一化;loop_control 默认只写 v2 键(legacy flag 才双写);effort 移除 max 档;实验 flags 补 remote-control、wait_for/minidb 标默认开启

This commit is contained in:
KimiSwitch Dev committed 2026-08-29 11:13:58 +08:00
1 parent 7435198fcc
commit 45ec073e6f
10 files changed
+306 -29

No files matched your search

+26 -5
View File
@@ -1,7 +1,14 @@
import { useEffect, useState } from "react";
import { invoke } from "@tauri-apps/api/core";
import { useTranslation } from "../i18n";
import type { TranslationKey } from "../i18n/zh";
import { getAgentSettings, setAgentSettings } from "../lib/agent-settings";
import type { AgentSettings, Hook, PermissionRule } from "../types";
import type {
AgentSettings,
ExperimentalEnvStatus,
Hook,
PermissionRule,
} from "../types";
import { Card, Checkbox, NumberField, Segmented } from "./ui/controls";
interface AgentSettingsPanelProps {
@@ -9,12 +16,12 @@ interface AgentSettingsPanelProps {
onChange: (nextRawOther: unknown) => void;
}
const THINKING_LEVELS = ["low", "medium", "high", "max"] as const;
// Upstream removed the "max" effort tier (auto-migrates to "high").
const THINKING_LEVELS = ["low", "medium", "high"] as const;
const THINKING_LABELS: Record<(typeof THINKING_LEVELS)[number], TranslationKey> = {
low: "thinkingLow",
medium: "thinkingMedium",
high: "thinkingHigh",
max: "thinkingMax",
};
const PERMISSION_DECISIONS = ["allow", "deny", "ask"] as const;
@@ -40,9 +47,23 @@ const COMMON_EVENTS = [
export function AgentSettingsPanel({ rawOther, onChange }: AgentSettingsPanelProps) {
const { t } = useTranslation();
const settings = getAgentSettings(rawOther);
/**
* KIMI_CODE_LEGACY_FLAG=1 keeps the v1 loop_control keys dual-written for
* v1-engine users; the default (v2) writes only max_attempts_per_step.
*/
const [legacyV1, setLegacyV1] = useState(false);
useEffect(() => {
invoke<ExperimentalEnvStatus>("get_experimental_env_status")
.then((env) => {
const value = env?.KIMI_CODE_LEGACY_FLAG ?? "";
setLegacyV1(["1", "true", "yes", "on"].includes(value.trim().toLowerCase()));
})
.catch(() => setLegacyV1(false));
}, []);
const update = (patch: Partial<AgentSettings>) => {
onChange(setAgentSettings(rawOther, patch));
onChange(setAgentSettings(rawOther, patch, { legacyV1 }));
};
const updateThinking = (patch: Partial<AgentSettings["thinking"]>) => {
@@ -95,7 +116,7 @@ export function AgentSettingsPanel({ rawOther, onChange }: AgentSettingsPanelPro
label={t("thinkingKeep")}
checked={settings.thinking?.keep === "all"}
disabled={!thinkingEnabled}
onChange={(checked) => updateThinking({ keep: checked ? "all" : false })}
onChange={(checked) => updateThinking({ keep: checked ? "all" : "off" })}
/>
<p className="text-xs text-content-muted">{t("thinkingContextHint")}</p>
</Card>
+21 -5
View File
@@ -9,6 +9,7 @@ import {
forcedEnvValue,
getExperimentalFlags,
getSubagentModelPool,
isExperimentalFlagSet,
isFlagLockedByEnv,
isMasterEnvOn,
removeSubagentPoolEntry,
@@ -33,12 +34,12 @@ interface SubagentSettingsPageProps {
onBack: () => void;
}
const EFFORTS = ["low", "medium", "high", "max"] as const;
// Upstream removed the "max" effort tier (auto-migrates to "high").
const EFFORTS = ["low", "medium", "high"] as const;
const EFFORT_LABELS: Record<(typeof EFFORTS)[number], TranslationKey> = {
low: "thinkingLow",
medium: "thinkingMedium",
high: "thinkingHigh",
max: "thinkingMax",
};
const FLAG_LABELS: Record<string, { name: TranslationKey; desc: TranslationKey }> = {
@@ -55,6 +56,7 @@ const FLAG_LABELS: Record<string, { name: TranslationKey; desc: TranslationKey }
name: "flagAutoSessionTitle",
desc: "flagAutoSessionTitleDesc",
},
"remote-control": { name: "flagRemoteControl", desc: "flagRemoteControlDesc" },
};
/** Validation-error i18n key per engine rule, for the pre-write self-check. */
@@ -235,7 +237,9 @@ export function SubagentSettingsPage({
? `${Math.round(n / 1000)}K`
: String(n);
const effortLabel = (e: string): string => {
const key = EFFORT_LABELS[e as (typeof EFFORTS)[number]];
// Stored "max" tiers from old configs are shown as "high" (upstream
// removed the tier; it auto-migrates to "high").
const key = EFFORT_LABELS[e === "max" ? "high" : (e as (typeof EFFORTS)[number])];
return key ? t(key) : e;
};
@@ -297,15 +301,27 @@ export function SubagentSettingsPage({
const renderFlagRow = (flag: ExperimentalFlagDef) => {
const labels = FLAG_LABELS[flag.id];
const locked = masterOn || isFlagLockedByEnv(env, flag);
// An explicitly written flag (true or false) wins; an absent flag falls
// back to the upstream default (`defaultEnabled`).
const explicitlySet = isExperimentalFlagSet(rawOther, flag.id);
const on = masterOn
? true
: isFlagLockedByEnv(env, flag)
? forcedEnvValue(env, flag)
: flags[flag.id] === true;
: explicitlySet
? flags[flag.id] === true
: (flag.defaultEnabled ?? false);
return (
<div key={flag.id} className="flex items-center gap-3">
<div className="flex-1 min-w-0">
<div className="text-sm text-content-primary">{t(labels.name)}</div>
<div className="flex items-center gap-2 text-sm text-content-primary">
{t(labels.name)}
{!locked && !explicitlySet && flag.defaultEnabled && (
<span className="shrink-0 text-xs text-blue-600 dark:text-blue-400 border border-blue-500/30 rounded px-1">
{t("flagDefaultOn")}
</span>
)}
</div>
<div className="text-xs text-content-muted">
{t(labels.desc)}
<code className="ml-2">{flag.envVar}</code>