Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-5853 feat(agent): support Kimi thinking levels (#6429)

Bowsercd9f4147a57d
diff --git a/server/pkg/agent/kimi.go b/server/pkg/agent/kimi.go
index 165e2629bb..b4fb1d3a90 100644
--- a/server/pkg/agent/kimi.go
+++ b/server/pkg/agent/kimi.go
@@ -329,6 +329,44 @@ func (b *kimiBackend) Execute(ctx context.Context, prompt string, opts ExecOptio
b.cfg.Logger.Info("kimi session model set", "model", opts.Model)
}
+ // 3b. Apply a persisted thinking override through Kimi's native ACP
+ // config option before prompting. As with other providers, a configuration
+ // failure does not block the task: the prompt goes out either way, and the
+ // warnings below are the only record that the level shown in the UI may not
+ // be the level in effect. Which level that is depends on how the call
+ // failed. If the request itself fails, the session keeps whatever it had
+ // beforehand — the CLI's own setting on a fresh session, the previous
+ // turn's level on a resumed one. If Kimi answers but confirms a different
+ // value, the session sits at that value. If it answers without a `thinking`
+ // currentValue at all, we cannot tell which level is in effect.
+ if opts.ThinkingLevel != "" {
+ configResult, err := c.request(runCtx, "session/set_config_option", map[string]any{
+ "sessionId": sessionID,
+ "configId": "thinking",
+ "value": opts.ThinkingLevel,
+ })
+ if err != nil {
+ b.cfg.Logger.Warn("kimi rejected the thinking level request; sending the prompt anyway",
+ "requested_level", opts.ThinkingLevel,
+ "effective_level", "unchanged",
+ "error", err,
+ )
+ } else {
+ effectiveLevel, confirmed := acpConfigOptionCurrentValue(configResult, "thinking")
+ if !confirmed || effectiveLevel != opts.ThinkingLevel {
+ if !confirmed {
+ effectiveLevel = "unknown"
+ }
+ b.cfg.Logger.Warn("kimi did not confirm the requested thinking level; sending the prompt anyway",
+ "requested_level", opts.ThinkingLevel,
+ "effective_level", effectiveLevel,
+ )
+ } else {
+ b.cfg.Logger.Info("kimi session thinking level confirmed", "level", effectiveLevel)
+ }
+ }
+ }
+
// 4. Build the prompt content. If we have a system prompt, prepend it.
userText := prompt
if opts.SystemPrompt != "" {
diff --git a/server/pkg/agent/kimi_test.go b/server/pkg/agent/kimi_test.go
index 0de17c94fa..a4ba7c0f57 100644
--- a/server/pkg/agent/kimi_test.go
+++ b/server/pkg/agent/kimi_test.go
@@ -7,6 +7,7 @@ import (
"log/slog"
"os"
"path/filepath"
+ "reflect"
"strconv"
"strings"
"testing"
@@ -151,6 +152,272 @@ func TestKimiBackendSetModelFailureFailsTask(t *testing.T) {
}
}
+func fakeKimiACPThinkingScript() string {
+ return `#!/bin/sh
+while IFS= read -r line; do
+ if [ -n "$KIMI_REQUESTS_FILE" ]; then
+ printf '%s\n' "$line" >> "$KIMI_REQUESTS_FILE"
+ fi
+ id=$(printf '%s' "$line" | sed -n 's/.*"id":\([0-9]*\).*/\1/p')
+ case "$line" in
+ *'"method":"initialize"'*)
+ printf '{"jsonrpc":"2.0","id":%s,"result":{"protocolVersion":1,"agentCapabilities":{"loadSession":true}}}\n' "$id"
+ ;;
+ *'"method":"session/new"'*)
+ printf '{"jsonrpc":"2.0","id":%s,"result":{"sessionId":"ses_thinking"}}\n' "$id"
+ ;;
+ *'"method":"session/resume"'*)
+ printf '{"jsonrpc":"2.0","id":%s,"result":{"sessionId":"ses_thinking"}}\n' "$id"
+ ;;
+ *'"method":"session/set_model"'*)
+ printf '{"jsonrpc":"2.0","id":%s,"result":{}}\n' "$id"
+ ;;
+ *'"method":"session/set_config_option"'*)
+ if [ "$KIMI_SET_CONFIG_ERROR" = "unsupported" ]; then
+ printf '{"jsonrpc":"2.0","id":%s,"error":{"code":-32602,"message":"Invalid params","data":{"value":"Unsupported thinking level"}}}\n' "$id"
+ continue
+ fi
+ requested=$(printf '%s' "$line" | sed -n 's/.*"value":"\([^"]*\)".*/\1/p')
+ if [ "$KIMI_SET_CONFIG_RESULT" = "mismatch" ]; then
+ printf '{"jsonrpc":"2.0","id":%s,"result":{"configOptions":[{"id":"thinking","currentValue":"low"}]}}\n' "$id"
+ elif [ "$KIMI_SET_CONFIG_RESULT" = "missing" ]; then
+ printf '{"jsonrpc":"2.0","id":%s,"result":{"configOptions":[]}}\n' "$id"
+ else
+ printf '{"jsonrpc":"2.0","id":%s,"result":{"configOptions":[{"id":"thinking","currentValue":"%s"}]}}\n' "$id" "$requested"
+ fi
+ ;;
+ *'"method":"session/prompt"'*)
+ printf '{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"ses_thinking","update":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"pong"}}}}\n'
+ printf '{"jsonrpc":"2.0","id":%s,"result":{"stopReason":"end_turn"}}\n' "$id"
+ exit 0
+ ;;
+ esac
+done
+`
+}
+
+func runKimiThinkingTest(t *testing.T, fakePath string, env map[string]string, opts ExecOptions) Result {
+ t.Helper()
+ backend, err := New("kimi", Config{
+ ExecutablePath: fakePath,
+ Logger: slog.Default(),
+ Env: env,
+ })
+ if err != nil {
+ t.Fatalf("new kimi backend: %v", err)
+ }
+ if opts.Timeout == 0 {
+ opts.Timeout = 5 * time.Second
+ }
+ session, err := backend.Execute(context.Background(), "reply with pong", opts)
+ if err != nil {
+ t.Fatalf("execute: %v", err)
+ }
+ go func() {
+ for range session.Messages {
+ }
+ }()
+ select {
+ case result := <-session.Result:
+ return result
+ case <-time.After(10 * time.Second):
+ t.Fatal("timeout waiting for result")
+ return Result{}
+ }
+}
+
+func TestKimiBackendSetsThinkingLevelBeforePrompt(t *testing.T) {
+ t.Parallel()
+ recordPath := filepath.Join(t.TempDir(), "requests.jsonl")
+ fakePath := filepath.Join(t.TempDir(), "kimi")
+ writeTestExecutable(t, fakePath, []byte(fakeKimiACPThinkingScript()))
+
+ result := runKimiThinkingTest(t, fakePath, map[string]string{
+ "KIMI_REQUESTS_FILE": recordPath,
+ }, ExecOptions{Model: "kimi-code/k3", ThinkingLevel: "high"})
+ if result.Status != "completed" {
+ t.Fatalf("status = %q, error = %q", result.Status, result.Error)
+ }
+
+ raw, err := os.ReadFile(recordPath)
+ if err != nil {
+ t.Fatalf("read recorded requests: %v", err)
+ }
+ var methods []string
+ var thinkingParams map[string]any
+ for _, line := range strings.Split(strings.TrimSpace(string(raw)), "\n") {
+ var frame map[string]any
+ if err := json.Unmarshal([]byte(line), &frame); err != nil {
+ t.Fatalf("decode recorded request: %v", err)
+ }
+ method, _ := frame["method"].(string)
+ methods = append(methods, method)
+ if method == "session/set_config_option" {
+ thinkingParams, _ = frame["params"].(map[string]any)
+ }
+ }
+ wantOrder := []string{"initialize", "session/new", "session/set_model", "session/set_config_option", "session/prompt"}
+ if !reflect.DeepEqual(methods, wantOrder) {
+ t.Fatalf("ACP method order = %v, want %v", methods, wantOrder)
+ }
+ if thinkingParams["sessionId"] != "ses_thinking" ||
+ thinkingParams["configId"] != "thinking" ||
+ thinkingParams["value"] != "high" {
+ t.Errorf("set_config_option params = %+v", thinkingParams)
+ }
+}
+
+func TestKimiBackendThinkingFailureWarnsAndContinues(t *testing.T) {
+ t.Parallel()
+ recordPath := filepath.Join(t.TempDir(), "requests.jsonl")
+ fakePath := filepath.Join(t.TempDir(), "kimi")
+ writeTestExecutable(t, fakePath, []byte(fakeKimiACPThinkingScript()))
+
+ result := runKimiThinkingTest(t, fakePath, map[string]string{
+ "KIMI_REQUESTS_FILE": recordPath,
+ "KIMI_SET_CONFIG_ERROR": "unsupported",
+ }, ExecOptions{Model: "kimi-code/k3", ThinkingLevel: "max"})
+ if result.Status != "completed" {
+ t.Fatalf("status = %q, error = %q", result.Status, result.Error)
+ }
+ raw, err := os.ReadFile(recordPath)
+ if err != nil {
+ t.Fatalf("read recorded requests: %v", err)
+ }
+ if !strings.Contains(string(raw), `"method":"session/prompt"`) {
+ t.Fatal("prompt was not sent after thinking configuration failed")
+ }
+}
+
+func TestKimiBackendThinkingConfirmationFailureWarnsAndContinues(t *testing.T) {
+ t.Parallel()
+
+ tests := []struct {
+ name string
+ result string
+ }{
+ {name: "mismatch", result: "mismatch"},
+ {name: "missing", result: "missing"},
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ t.Parallel()
+ recordPath := filepath.Join(t.TempDir(), "requests.jsonl")
+ fakePath := filepath.Join(t.TempDir(), "kimi")
+ writeTestExecutable(t, fakePath, []byte(fakeKimiACPThinkingScript()))
+
+ result := runKimiThinkingTest(t, fakePath, map[string]string{
+ "KIMI_REQUESTS_FILE": recordPath,
+ "KIMI_SET_CONFIG_RESULT": tt.result,
+ }, ExecOptions{Model: "kimi-code/k3", ThinkingLevel: "max"})
+ if result.Status != "completed" {
+ t.Fatalf("status = %q, error = %q", result.Status, result.Error)
+ }
+ if result.ResumeRejected {
+ t.Fatal("confirmation failure must not be classified as a rejected resume")
+ }
+ raw, err := os.ReadFile(recordPath)
+ if err != nil {
+ t.Fatalf("read recorded requests: %v", err)
+ }
+ if !strings.Contains(string(raw), `"method":"session/prompt"`) {
+ t.Fatal("prompt was not sent after thinking confirmation failed")
+ }
+ })
+ }
+}
+
+func TestKimiBackendOmitsThinkingConfigWhenUnset(t *testing.T) {
+ t.Parallel()
+ recordPath := filepath.Join(t.TempDir(), "requests.jsonl")
+ fakePath := filepath.Join(t.TempDir(), "kimi")
+ writeTestExecutable(t, fakePath, []byte(fakeKimiACPThinkingScript()))
+
+ result := runKimiThinkingTest(t, fakePath, map[string]string{
+ "KIMI_REQUESTS_FILE": recordPath,
+ }, ExecOptions{Model: "kimi-code/k3"})
+ if result.Status != "completed" {
+ t.Fatalf("status = %q, error = %q", result.Status, result.Error)
+ }
+ raw, err := os.ReadFile(recordPath)
+ if err != nil {
+ t.Fatalf("read recorded requests: %v", err)
+ }
+ if strings.Contains(string(raw), `"method":"session/set_config_option"`) {
+ t.Fatal("thinking config was sent for an empty override")
+ }
+}
+
+// recordedKimiMethods returns the ACP method names the fake binary saw, in
+// order, from the file $KIMI_REQUESTS_FILE points at.
+func recordedKimiMethods(t *testing.T, recordPath string) []string {
+ t.Helper()
+ raw, err := os.ReadFile(recordPath)
+ if err != nil {
+ t.Fatalf("read recorded requests: %v", err)
+ }
+ var methods []string
+ for _, line := range strings.Split(strings.TrimSpace(string(raw)), "\n") {
+ var frame map[string]any
+ if err := json.Unmarshal([]byte(line), &frame); err != nil {
+ t.Fatalf("decode recorded request: %v", err)
+ }
+ method, _ := frame["method"].(string)
+ methods = append(methods, method)
+ }
+ return methods
+}
+
+// TestKimiBackendSetsThinkingLevelOnResumedSession covers the half of the
+// contract the fresh-session tests miss: a resumed session already carries
+// whatever thinking level its previous turn left behind, so the configured
+// level has to be re-applied — still before session/prompt, and without a
+// session/set_model call to piggyback on.
+func TestKimiBackendSetsThinkingLevelOnResumedSession(t *testing.T) {
+ t.Parallel()
+ recordPath := filepath.Join(t.TempDir(), "requests.jsonl")
+ fakePath := filepath.Join(t.TempDir(), "kimi")
+ writeTestExecutable(t, fakePath, []byte(fakeKimiACPThinkingScript()))
+
+ result := runKimiThinkingTest(t, fakePath, map[string]string{
+ "KIMI_REQUESTS_FILE": recordPath,
+ }, ExecOptions{ResumeSessionID: "ses_thinking", ThinkingLevel: "high"})
+ if result.Status != "completed" {
+ t.Fatalf("status = %q, error = %q", result.Status, result.Error)
+ }
+
+ wantOrder := []string{"initialize", "session/resume", "session/set_config_option", "session/prompt"}
+ if methods := recordedKimiMethods(t, recordPath); !reflect.DeepEqual(methods, wantOrder) {
+ t.Fatalf("ACP method order = %v, want %v", methods, wantOrder)
+ }
+}
+
+// TestKimiBackendOmitsThinkingConfigOnResumedSessionWhenUnset states the known
+// gap deliberately rather than leaving it undefined: with no configured level,
+// the backend sends nothing, so a resumed session keeps the level its previous
+// turn set. Switching an agent back to "Follow CLI config" therefore does not
+// clear a level already applied to a live session. Changing that means
+// deciding what "follow the CLI config" resolves to on the wire, which is
+// tracked separately; until then this test is what makes the behaviour visible.
+func TestKimiBackendOmitsThinkingConfigOnResumedSessionWhenUnset(t *testing.T) {
+ t.Parallel()
+ recordPath := filepath.Join(t.TempDir(), "requests.jsonl")
+ fakePath := filepath.Join(t.TempDir(), "kimi")
+ writeTestExecutable(t, fakePath, []byte(fakeKimiACPThinkingScript()))
+
+ result := runKimiThinkingTest(t, fakePath, map[string]string{
+ "KIMI_REQUESTS_FILE": recordPath,
+ }, ExecOptions{ResumeSessionID: "ses_thinking"})
+ if result.Status != "completed" {
+ t.Fatalf("status = %q, error = %q", result.Status, result.Error)
+ }
+
+ wantOrder := []string{"initialize", "session/resume", "session/prompt"}
+ if methods := recordedKimiMethods(t, recordPath); !reflect.DeepEqual(methods, wantOrder) {
+ t.Fatalf("ACP method order = %v, want %v", methods, wantOrder)
+ }
+}
+
// fakeKimiACPStaleResumeSetModelScript impersonates kimi-cli when a
// resumed session is gone and the caller picked a model:
// session/resume echoes the requested sessionId back, then
diff --git a/server/pkg/agent/models.go b/server/pkg/agent/models.go
index 293a114f2f..c713f8e149 100644
--- a/server/pkg/agent/models.go
+++ b/server/pkg/agent/models.go
@@ -121,10 +121,11 @@ const modelCacheTTL = 60 * time.Second
// pi, openclaw) it shells out with caching and falls back where the
// provider has a safe static catalog.
//
-// For claude, codex, opencode, and pi, the catalog is augmented with per-model
-// thinking-level options discovered from the local CLI. Codex discovery
-// failures fall back to a model + thinking snapshot; providers without a safe
-// fallback leave Thinking nil, which makes the UI hide the thinking picker.
+// For claude, codex, opencode, pi, and kimi, the catalog is augmented with
+// per-model thinking-level options discovered from the local CLI. Codex
+// discovery failures fall back to a model + thinking snapshot; providers
+// without a safe fallback leave Thinking nil, which makes the UI hide the
+// thinking picker.
//
// executablePath lets the caller point at a non-default binary; pass
// "" to use the provider's default name on PATH.
@@ -1151,21 +1152,262 @@ func discoverHermesModels(ctx context.Context, executablePath string) ([]Model,
})
}
-// discoverKimiModels spins up a throwaway `kimi acp` process and
-// drives the same minimal ACP handshake as Hermes to surface the
-// model catalog advertised by Kimi's `session/new` response. Kimi
-// ≤0.28 returns a `models` block (`availableModels`/`currentModelId`);
-// 0.29 moved the same catalog into `configOptions` (MUL-5239). The
-// shared parser accepts both, so the discovery path stays identical.
+// discoverKimiModels combines Kimi's ACP model catalog with the structured
+// per-model effort data from `kimi provider list --json`. The provider catalog
+// is the only authoritative source for per-model supportEfforts/defaultEffort,
+// because a session/new response only ever describes the single model that
+// session was created with.
//
-// Failure modes (kimi missing, not logged in, config error) all
-// return an empty list so the UI falls back to manual entry.
+// Reading the effort catalog out of the session instead does not work, even
+// though Kimi (0.33.0) does refresh the thinking option after
+// session/set_model. The refreshed option arrives as a `session/update`
+// notification (`sessionUpdate: "config_option_update"`), and the requestACP
+// helper this file shares matches responses by id and drops notifications.
+// Consuming that notification would not be enough either: the option list Kimi
+// sends after switching to a low/high/max model still carries the previous
+// model's currentValue as a trailing entry (`[low, high, max, on]`), so using
+// it as a catalog would render a phantom level. supportEfforts has no such
+// residue.
+//
+// The ACP side is unchanged: Kimi ≤0.28 returns a `models` block
+// (`availableModels`/`currentModelId`) and 0.29 moved the same catalog into
+// `configOptions` (MUL-5239); the shared parser still accepts both, so the
+// discovery path stays identical. See parseACPConfigOptionModels.
+//
+// Effort selection is gated on the CLI build, because provider-list alone
+// cannot tell whether the runtime can act on what it advertises. Verified
+// against real binaries: 0.28.1 reports supportEfforts [low high max] for K3
+// exactly like 0.33.0 does, but its ACP only implements the on/off toggle, so
+// set_config_option("max") returns success while confirming "on". Gating on the
+// session's `thinking` config id cannot separate the two — 0.28.1 advertises
+// that id too. The version is the only honest signal, and the initialize
+// response already carries it, so this costs no extra process.
+//
+// Above that, support is decided per model and nothing else: a model that
+// provider-list does not list, or lists without efforts, keeps Thinking nil,
+// which hides the control for that model alone.
+//
+// Failure modes (kimi missing, not logged in, config error) return an empty
+// list so the UI falls back to manual entry.
func discoverKimiModels(ctx context.Context, executablePath string) ([]Model, error) {
- return discoverACPModels(ctx, executablePath, acpDiscoveryProvider{
+ var acpVersion string
+ models, err := discoverACPModels(ctx, executablePath, acpDiscoveryProvider{
defaultBin: "kimi",
clientName: "multica-model-discovery",
tmpdirPrefix: "multica-kimi-discovery-",
+ inspectInit: func(initResult json.RawMessage) {
+ acpVersion = acpAgentInfoVersion(initResult)
+ },
})
+ if err != nil || len(models) == 0 {
+ return models, err
+ }
+ if !kimiSupportsThinkingEfforts(acpVersion) {
+ // Not an error and not worth a Warn: an older CLI still lists models and
+ // runs tasks, it just cannot be told which effort to use. Model discovery
+ // re-runs on every cache miss, so a Warn here would repeat forever.
+ slog.Debug("kimi CLI predates ACP effort selection; hiding thinking controls",
+ "detected_version", acpVersion,
+ "required_version", kimiMinThinkingEffortVersion,
+ )
+ return models, nil
+ }
+
+ perModel, err := discoverKimiProviderThinking(ctx, executablePath)
+ if err != nil {
+ // Do not include err or command output here: provider JSON can contain
+ // credentials. The fixed reason explains why thinking controls are hidden
+ // without leaking host or account data. Debug, not Warn: model discovery
+ // re-runs on every cache miss, so an older CLI would log this forever.
+ slog.Debug("kimi per-model thinking discovery unavailable; hiding thinking controls",
+ "reason", "provider_list_unavailable",
+ )
+ return models, nil
+ }
+ for i := range models {
+ if thinking, ok := perModel[models[i].ID]; ok {
+ models[i].Thinking = thinking
+ }
+ }
+ return models, nil
+}
+
+// kimiMinThinkingEffortVersion is the first Kimi Code CLI whose ACP surface
+// applies an effort level instead of a plain on/off toggle (upstream 0.29.0,
+// released 2026-07-22). Below it, `session/set_config_option` accepts
+// "low"/"high"/"max" without error and leaves the session on "on", so
+// advertising those levels would promise something the runtime cannot deliver.
+const kimiMinThinkingEffortVersion = "0.29.0"
+
+// kimiSupportsThinkingEfforts reports whether an ACP-reported Kimi version can
+// act on an effort level. An empty or unparsable version answers no: a build we
+// cannot identify (a fork, a wrapper, a future format) is not one we can
+// promise effort selection for, and hiding the picker only costs that build a
+// control it may not honour anyway. Tasks still run either way.
+func kimiSupportsThinkingEfforts(version string) bool {
+ detected, err := parseSemver(strings.TrimSpace(version))
+ if err != nil {
+ return false
+ }
+ minimum, err := parseSemver(kimiMinThinkingEffortVersion)
+ if err != nil {
+ return false
+ }
+ return !detected.lessThan(minimum)
+}
+
+// acpAgentInfoVersion pulls `agentInfo.version` out of an ACP initialize
+// result. ACP agents report their own build here (Kimi sends
+// {"name":"Kimi Code CLI","version":"0.33.0"}); an agent that omits it yields
+// "", which every caller must treat as "unknown", never as "new enough".
+func acpAgentInfoVersion(raw json.RawMessage) string {
+ var response struct {
+ AgentInfo struct {
+ Version string `json:"version"`
+ } `json:"agentInfo"`
+ AgentInfoSnake struct {
+ Version string `json:"version"`
+ } `json:"agent_info"`
+ }
+ if err := json.Unmarshal(raw, &response); err != nil {
+ return ""
+ }
+ if version := strings.TrimSpace(response.AgentInfo.Version); version != "" {
+ return version
+ }
+ return strings.TrimSpace(response.AgentInfoSnake.Version)
+}
+
+func discoverKimiProviderThinking(ctx context.Context, executablePath string) (map[string]*ModelThinking, error) {
+ if executablePath == "" {
+ executablePath = "kimi"
+ }
+ runCtx, cancel := context.WithTimeout(ctx, 15*time.Second)
+ defer cancel()
+
+ cmd := exec.CommandContext(runCtx, executablePath, "provider", "list", "--json")
+ hideAgentWindow(cmd)
+ cmd.Stderr = io.Discard
+ raw, err := cmd.Output()
+ if err != nil {
+ return nil, fmt.Errorf("kimi provider list: %w", err)
+ }
+ return parseKimiProviderThinking(raw)
+}
+
+type kimiProviderModel struct {
+ SupportEfforts []string `json:"supportEfforts"`
+ SupportEffortsSnake []string `json:"support_efforts"`
+ DefaultEffort string `json:"defaultEffort"`
+ DefaultEffortSnake string `json:"default_effort"`
+}
+
+func parseKimiProviderThinking(raw []byte) (map[string]*ModelThinking, error) {
+ var response struct {
+ Models map[string]kimiProviderModel `json:"models"`
+ }
+ if err := json.Unmarshal(raw, &response); err != nil {
+ return nil, fmt.Errorf("parse kimi provider catalog: %w", err)
+ }
+ if len(response.Models) == 0 {
+ return nil, fmt.Errorf("kimi provider catalog contained no models")
+ }
+
+ result := make(map[string]*ModelThinking, len(response.Models))
+ for modelID, model := range response.Models {
+ modelID = strings.TrimSpace(modelID)
+ if modelID == "" {
+ continue
+ }
+ efforts := model.SupportEfforts
+ if len(efforts) == 0 {
+ efforts = model.SupportEffortsSnake
+ }
+ seen := make(map[string]bool, len(efforts))
+ levels := make([]ThinkingLevel, 0, len(efforts))
+ for _, rawEffort := range efforts {
+ effort := strings.TrimSpace(rawEffort)
+ if effort == "" || seen[effort] || !isValidDynamicThinkingValue(effort) {
+ continue
+ }
+ seen[effort] = true
+ levels = append(levels, ThinkingLevel{
+ Value: effort,
+ Label: kimiThinkingLabel(effort),
+ })
+ }
+ if len(levels) == 0 {
+ continue
+ }
+
+ defaultEffort := strings.TrimSpace(model.DefaultEffort)
+ if defaultEffort == "" {
+ defaultEffort = strings.TrimSpace(model.DefaultEffortSnake)
+ }
+ if !seen[defaultEffort] {
+ defaultEffort = ""
+ }
+ result[modelID] = &ModelThinking{
+ SupportedLevels: levels,
+ DefaultLevel: defaultEffort,
+ }
+ }
+ return result, nil
+}
+
+func kimiThinkingLabel(value string) string {
+ switch value {
+ case "low":
+ return "Low"
+ case "medium":
+ return "Medium"
+ case "high":
+ return "High"
+ case "max":
+ return "Max"
+ default:
+ return strings.Title(value) //nolint:staticcheck
+ }
+}
+
+type acpConfigOptionState struct {
+ ID string `json:"id"`
+ CurrentValue string `json:"currentValue"`
+ CurrentValueSnake string `json:"current_value"`
+}
+
+// findACPConfigOption returns one exact config-id match from an ACP response.
+// Config ids are protocol identifiers, not display labels: category-only or
+// case-insensitive matches would advertise a control that execution cannot set.
+// Both camelCase and snake_case field spellings are accepted because ACP agents
+// in the wild emit both.
+func findACPConfigOption(raw json.RawMessage, configID string) (acpConfigOptionState, bool) {
+ var response struct {
+ ConfigOptions []acpConfigOptionState `json:"configOptions"`
+ ConfigOptionsSnake []acpConfigOptionState `json:"config_options"`
+ }
+ if err := json.Unmarshal(raw, &response); err != nil {
+ return acpConfigOptionState{}, false
+ }
+ options := append(response.ConfigOptions, response.ConfigOptionsSnake...)
+ for _, option := range options {
+ if option.ID == configID {
+ return option, true
+ }
+ }
+ return acpConfigOptionState{}, false
+}
+
+func acpConfigOptionCurrentValue(raw json.RawMessage, configID string) (string, bool) {
+ option, ok := findACPConfigOption(raw, configID)
+ if !ok {
+ return "", false
+ }
+ value := strings.TrimSpace(option.CurrentValue)
+ if value == "" {
+ value = strings.TrimSpace(option.CurrentValueSnake)
+ }
+ return value, value != ""
}
// discoverReasonixModels drives a short Reasonix ACP session and parses the
@@ -1271,6 +1513,13 @@ type acpDiscoveryProvider struct {
// ignores. CodeBuddy uses it to read its effort catalog out of the same
// handshake, which is why it needs no separate discovery call at all.
annotate func([]Model, json.RawMessage)
+ // inspectInit receives the raw initialize result before any session is
+ // created. It is for reading capability facts the handshake already
+ // carries — Kimi reads `agentInfo.version` to gate a feature on the CLI
+ // build — so a provider does not have to spend a second process asking the
+ // binary what it is. It cannot fail discovery: a provider that learns
+ // nothing useful here must degrade, not abort.
+ inspectInit func(json.RawMessage)
}
// discoverACPModels runs the ACP handshake for any agent CLI that
@@ -1410,6 +1659,9 @@ func discoverACPModels(ctx context.Context, executablePath string, p acpDiscover
if err != nil {
return fail("initialize", err)
}
+ if p.inspectInit != nil {
+ p.inspectInit(initResult)
+ }
// session/new requires a valid cwd — use a temp directory we
// clean up afterwards, not the daemon's workdir (which might
diff --git a/server/pkg/agent/models_test.go b/server/pkg/agent/models_test.go
index 749f3d5a76..315ce220f0 100644
--- a/server/pkg/agent/models_test.go
+++ b/server/pkg/agent/models_test.go
@@ -2,6 +2,7 @@ package agent
import (
"context"
+ "fmt"
"path/filepath"
"reflect"
"runtime"
@@ -77,6 +78,394 @@ func TestListModelsCopilotFallsBackToStatic(t *testing.T) {
}
}
+func TestParseKimiProviderThinking(t *testing.T) {
+ t.Parallel()
+ raw := []byte(`{
+ "models": {
+ "kimi-code/kimi-for-coding": {
+ "displayName": "K2.7 Coding"
+ },
+ "kimi-code/k3": {
+ "supportEfforts": ["low", "high", "max", "high", "bad value"],
+ "defaultEffort": "high"
+ },
+ "kimi-code/k3-256k": {
+ "support_efforts": ["low", "max"],
+ "default_effort": "missing"
+ }
+ }
+}`)
+
+ got, err := parseKimiProviderThinking(raw)
+ if err != nil {
+ t.Fatalf("parseKimiProviderThinking: %v", err)
+ }
+ if thinking, ok := got["kimi-code/kimi-for-coding"]; ok {
+ t.Fatalf("model without supportEfforts = %+v, want no entry at all", thinking)
+ }
+ k3 := got["kimi-code/k3"]
+ if k3 == nil {
+ t.Fatal("k3 thinking catalog is nil")
+ }
+ if k3.DefaultLevel != "high" {
+ t.Errorf("k3 default = %q, want high", k3.DefaultLevel)
+ }
+ if values := thinkingValues(k3); !reflect.DeepEqual(values, []string{"low", "high", "max"}) {
+ t.Errorf("k3 levels = %v, want [low high max]", values)
+ }
+ if labels := []string{k3.SupportedLevels[0].Label, k3.SupportedLevels[1].Label, k3.SupportedLevels[2].Label}; !reflect.DeepEqual(labels, []string{"Low", "High", "Max"}) {
+ t.Errorf("k3 labels = %v, want [Low High Max]", labels)
+ }
+ k3Short := got["kimi-code/k3-256k"]
+ if k3Short == nil {
+ t.Fatal("snake_case k3-256k thinking catalog is nil")
+ }
+ if k3Short.DefaultLevel != "" {
+ t.Errorf("unsupported default = %q, want empty", k3Short.DefaultLevel)
+ }
+}
+
+func TestFindACPConfigOptionRequiresExactID(t *testing.T) {
+ t.Parallel()
+ raw := []byte(`{
+ "config_options": [{
+ "type": "select",
+ "id": "thinking",
+ "category": "thought_level",
+ "current_value": "high"
+ }]
+}`)
+ option, ok := findACPConfigOption(raw, "thinking")
+ if !ok || option.ID != "thinking" {
+ t.Fatalf("findACPConfigOption = (%+v, %v), want exact thinking option", option, ok)
+ }
+ value, ok := acpConfigOptionCurrentValue(raw, "thinking")
+ if !ok || value != "high" {
+ t.Errorf("acpConfigOptionCurrentValue = (%q, %v), want (high, true)", value, ok)
+ }
+
+ for _, invalidID := range []string{"reasoning", "Thinking", " thinking "} {
+ renamed := []byte(fmt.Sprintf(`{"configOptions":[{"id":%q,"category":"thought_level","currentValue":"high"}]}`, invalidID))
+ if option, ok := findACPConfigOption(renamed, "thinking"); ok {
+ t.Fatalf("non-exact id %q exposed config option: %+v", invalidID, option)
+ }
+ }
+}
+
+func TestDiscoverKimiModelsAnnotatesThinkingPerModel(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("shell-script fake binary requires a POSIX shell")
+ }
+ t.Parallel()
+
+ script := `#!/bin/sh
+if [ "$1" = "provider" ]; then
+ printf '%s\n' '{"models":{"kimi-code/kimi-for-coding":{"displayName":"K2.7 Coding"},"kimi-code/k3":{"supportEfforts":["low","high","max"],"defaultEffort":"high"},"kimi-code/k3-256k":{"supportEfforts":["low","high","max"],"defaultEffort":"high"}}}'
+ exit 0
+fi
+while IFS= read -r line; do
+ id=$(printf '%s' "$line" | sed -n 's/.*"id":\([0-9]*\).*/\1/p')
+ case "$line" in
+ *'"method":"initialize"'*)
+ printf '{"jsonrpc":"2.0","id":%s,"result":{"protocolVersion":1,"agentCapabilities":{},"agentInfo":{"name":"Kimi Code CLI","version":"0.33.0"}}}\n' "$id"
+ ;;
+ *'"method":"session/new"'*)
+ printf '{"jsonrpc":"2.0","id":%s,"result":{"sessionId":"test-session","configOptions":[{"type":"select","id":"model","category":"model","currentValue":"kimi-code/k3","options":[{"value":"kimi-code/kimi-for-coding","name":"K2.7 Coding"},{"value":"kimi-code/k3","name":"K3"},{"value":"kimi-code/k3-256k","name":"K3-256k"}]},{"type":"select","id":"thinking","category":"thought_level","currentValue":"high","options":[{"value":"low","name":"Low"},{"value":"high","name":"High"},{"value":"max","name":"Max"}]}]}}\n' "$id"
+ ;;
+ esac
+done
+`
+ fake := filepath.Join(t.TempDir(), "kimi")
+ writeTestExecutable(t, fake, []byte(script))
+
+ models, err := discoverKimiModels(context.Background(), fake)
+ if err != nil {
+ t.Fatalf("discoverKimiModels: %v", err)
+ }
+ byID := make(map[string]Model, len(models))
+ for _, model := range models {
+ byID[model.ID] = model
+ }
+ if byID["kimi-code/kimi-for-coding"].Thinking != nil {
+ t.Errorf("kimi-for-coding must not inherit the current model's efforts: %+v", byID["kimi-code/kimi-for-coding"].Thinking)
+ }
+ for _, id := range []string{"kimi-code/k3", "kimi-code/k3-256k"} {
+ thinking := byID[id].Thinking
+ if thinking == nil || thinking.DefaultLevel != "high" ||
+ !reflect.DeepEqual(thinkingValues(thinking), []string{"low", "high", "max"}) {
+ t.Errorf("%s thinking = %+v", id, thinking)
+ }
+ }
+
+ valid, err := ValidateThinkingLevel(context.Background(), "kimi", fake, "kimi-code/k3", "high")
+ if err != nil || !valid {
+ t.Errorf("ValidateThinkingLevel(k3, high) = (%v, %v), want (true, nil)", valid, err)
+ }
+ // Unsupported persisted values are ordinary catalog results, not discovery
+ // errors. The daemon logs a warning, ignores the value, and starts the task
+ // with the runtime's own setting, just as it does for other providers.
+ valid, err = ValidateThinkingLevel(context.Background(), "kimi", fake, "kimi-code/k3", "medium")
+ if err != nil || valid {
+ t.Errorf("ValidateThinkingLevel(k3, medium) = (%v, %v), want unsupported without an error", valid, err)
+ }
+ valid, err = ValidateThinkingLevel(context.Background(), "kimi", fake, "kimi-code/kimi-for-coding", "high")
+ if err != nil || valid {
+ t.Errorf("ValidateThinkingLevel(kimi-for-coding, high) = (%v, %v), want unsupported without an error", valid, err)
+ }
+}
+
+func TestDiscoverKimiModelsProviderListFailureHidesThinking(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("shell-script fake binary requires a POSIX shell")
+ }
+ t.Parallel()
+
+ script := `#!/bin/sh
+if [ "$1" = "provider" ]; then
+ exit 1
+fi
+while IFS= read -r line; do
+ id=$(printf '%s' "$line" | sed -n 's/.*"id":\([0-9]*\).*/\1/p')
+ case "$line" in
+ *'"method":"initialize"'*)
+ printf '{"jsonrpc":"2.0","id":%s,"result":{"protocolVersion":1,"agentCapabilities":{},"agentInfo":{"name":"Kimi Code CLI","version":"0.33.0"}}}\n' "$id"
+ ;;
+ *'"method":"session/new"'*)
+ printf '{"jsonrpc":"2.0","id":%s,"result":{"sessionId":"test-session","configOptions":[{"type":"select","id":"model","category":"model","currentValue":"kimi-code/kimi-for-coding","options":[{"value":"kimi-code/kimi-for-coding","name":"K2.7 Coding"},{"value":"kimi-code/k3","name":"K3"}]},{"type":"select","id":"thinking","category":"thought_level","currentValue":"high","options":[{"value":"low","name":"Low"},{"value":"high","name":"High"}]}]}}\n' "$id"
+ ;;
+ esac
+done
+`
+ fake := filepath.Join(t.TempDir(), "kimi")
+ writeTestExecutable(t, fake, []byte(script))
+
+ models, err := discoverKimiModels(context.Background(), fake)
+ if err != nil {
+ t.Fatalf("discoverKimiModels: %v", err)
+ }
+ byID := make(map[string]Model, len(models))
+ for _, model := range models {
+ byID[model.ID] = model
+ }
+ for _, id := range []string{"kimi-code/kimi-for-coding", "kimi-code/k3"} {
+ if thinking := byID[id].Thinking; thinking != nil {
+ t.Errorf("%s received session-local thinking after provider-list failure: %+v", id, thinking)
+ }
+ }
+}
+
+func TestDiscoverKimiModelsDoesNotMigrateSessionThinkingToAnotherModel(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("shell-script fake binary requires a POSIX shell")
+ }
+ t.Parallel()
+
+ script := `#!/bin/sh
+if [ "$1" = "provider" ]; then
+ printf '%s\n' '{"models":{"kimi-code/kimi-for-coding":{"displayName":"K2.7 Coding"}}}'
+ exit 0
+fi
+while IFS= read -r line; do
+ id=$(printf '%s' "$line" | sed -n 's/.*"id":\([0-9]*\).*/\1/p')
+ case "$line" in
+ *'"method":"initialize"'*)
+ printf '{"jsonrpc":"2.0","id":%s,"result":{"protocolVersion":1,"agentCapabilities":{},"agentInfo":{"name":"Kimi Code CLI","version":"0.33.0"}}}\n' "$id"
+ ;;
+ *'"method":"session/new"'*)
+ printf '{"jsonrpc":"2.0","id":%s,"result":{"sessionId":"test-session","configOptions":[{"id":"model","category":"model","currentValue":"kimi-code/k3","options":[{"value":"kimi-code/kimi-for-coding","name":"K2.7 Coding"},{"value":"kimi-code/k3","name":"K3"}]},{"id":"thinking","category":"thought_level","currentValue":"high","options":[{"value":"low","name":"Low"},{"value":"high","name":"High"}]}]}}\n' "$id"
+ ;;
+ esac
+done
+`
+ fake := filepath.Join(t.TempDir(), "kimi")
+ writeTestExecutable(t, fake, []byte(script))
+
+ models, err := discoverKimiModels(context.Background(), fake)
+ if err != nil {
+ t.Fatalf("discoverKimiModels: %v", err)
+ }
+ for _, model := range models {
+ if model.Thinking != nil {
+ t.Errorf("%s received thinking from a different ACP session model: %+v", model.ID, model.Thinking)
+ }
+ }
+}
+
+// TestDiscoverKimiModelsIgnoresTheDiscoverySessionsOwnThinkingSupport pins the
+// per-model rule against the case that makes a session-wide gate wrong. The CLI
+// default model here has no thinking capability at all, so Kimi's session/new
+// omits the `thinking` config id entirely — yet K3 still advertises
+// supportEfforts in the provider catalog and must keep its levels. The mirror
+// case matters just as much: the session does advertise thinking, but that says
+// nothing about a model provider-list gives no efforts for.
+func TestDiscoverKimiModelsIgnoresTheDiscoverySessionsOwnThinkingSupport(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("shell-script fake binary requires a POSIX shell")
+ }
+ t.Parallel()
+
+ script := `#!/bin/sh
+if [ "$1" = "provider" ]; then
+ printf '%s\n' '{"models":{"kimi-code/kimi-for-coding":{"displayName":"K2.7 Coding"},"kimi-code/k3":{"supportEfforts":["low","high","max"],"defaultEffort":"high"}}}'
+ exit 0
+fi
+while IFS= read -r line; do
+ id=$(printf '%s' "$line" | sed -n 's/.*"id":\([0-9]*\).*/\1/p')
+ case "$line" in
+ *'"method":"initialize"'*)
+ printf '{"jsonrpc":"2.0","id":%s,"result":{"protocolVersion":1,"agentCapabilities":{},"agentInfo":{"name":"Kimi Code CLI","version":"0.33.0"}}}\n' "$id"
+ ;;
+ *'"method":"session/new"'*)
+ printf '{"jsonrpc":"2.0","id":%s,"result":{"sessionId":"test-session","configOptions":[{"type":"select","id":"model","category":"model","currentValue":"kimi-code/kimi-for-coding","options":[{"value":"kimi-code/kimi-for-coding","name":"K2.7 Coding"},{"value":"kimi-code/k3","name":"K3"}]}]}}\n' "$id"
+ ;;
+ esac
+done
+`
+ fake := filepath.Join(t.TempDir(), "kimi")
+ writeTestExecutable(t, fake, []byte(script))
+
+ models, err := discoverKimiModels(context.Background(), fake)
+ if err != nil {
+ t.Fatalf("discoverKimiModels: %v", err)
+ }
+ byID := make(map[string]Model, len(models))
+ for _, model := range models {
+ byID[model.ID] = model
+ }
+ k3 := byID["kimi-code/k3"].Thinking
+ if k3 == nil || k3.DefaultLevel != "high" ||
+ !reflect.DeepEqual(thinkingValues(k3), []string{"low", "high", "max"}) {
+ t.Errorf("k3 lost its efforts because the default model has none: %+v", k3)
+ }
+ if thinking := byID["kimi-code/kimi-for-coding"].Thinking; thinking != nil {
+ t.Errorf("kimi-for-coding has no efforts in the provider catalog: %+v", thinking)
+ }
+}
+
+// TestDiscoverKimiModelsHidesThinkingBelowTheEffortCapableCLI covers the case
+// provider-list cannot detect on its own. Checked against the real binaries:
+// Kimi 0.28.1 reports K3's supportEfforts exactly like 0.33.0 does, but its ACP
+// only implements the on/off toggle — set_config_option("max") answers success
+// while confirming "on". Advertising Low/High/Max there would let a user save a
+// level the runtime silently ignores, so the version decides.
+func TestDiscoverKimiModelsHidesThinkingBelowTheEffortCapableCLI(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("shell-script fake binary requires a POSIX shell")
+ }
+ t.Parallel()
+
+ // The `thinking` config id is present here on purpose: 0.28.1 advertises it
+ // too, which is exactly why it cannot stand in for the capability check.
+ script := `#!/bin/sh
+if [ "$1" = "provider" ]; then
+ printf '%s\n' '{"models":{"kimi-code/k3":{"supportEfforts":["low","high","max"],"defaultEffort":"high"}}}'
+ exit 0
+fi
+while IFS= read -r line; do
+ id=$(printf '%s' "$line" | sed -n 's/.*"id":\([0-9]*\).*/\1/p')
+ case "$line" in
+ *'"method":"initialize"'*)
+ printf '{"jsonrpc":"2.0","id":%s,"result":{"protocolVersion":1,"agentCapabilities":{},"agentInfo":{"name":"Kimi Code CLI","version":"VERSION"}}}\n' "$id"
+ ;;
+ *'"method":"session/new"'*)
+ printf '{"jsonrpc":"2.0","id":%s,"result":{"sessionId":"test-session","configOptions":[{"id":"model","category":"model","currentValue":"kimi-code/k3","options":[{"value":"kimi-code/k3","name":"K3"}]},{"id":"thinking","category":"thought_level","currentValue":"on","options":[{"value":"off","name":"Off"},{"value":"on","name":"On"}]}]}}\n' "$id"
+ ;;
+ esac
+done
+`
+ tests := []struct {
+ name string
+ version string
+ wantThinking bool
+ }{
+ {name: "0.28.1 applies on/off only", version: "0.28.1", wantThinking: false},
+ {name: "0.29.0 is the first effort-capable build", version: "0.29.0", wantThinking: true},
+ {name: "unidentifiable build stays hidden", version: "", wantThinking: false},
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ t.Parallel()
+ fake := filepath.Join(t.TempDir(), "kimi")
+ writeTestExecutable(t, fake, []byte(strings.Replace(script, "VERSION", tt.version, 1)))
+
+ models, err := discoverKimiModels(context.Background(), fake)
+ if err != nil {
+ t.Fatalf("discoverKimiModels: %v", err)
+ }
+ if len(models) == 0 {
+ t.Fatal("model discovery must keep working on every CLI build")
+ }
+ var k3 *ModelThinking
+ for _, model := range models {
+ if model.ID == "kimi-code/k3" {
+ k3 = model.Thinking
+ }
+ }
+ if got := k3 != nil; got != tt.wantThinking {
+ t.Errorf("k3 thinking present = %v, want %v (version %q): %+v", got, tt.wantThinking, tt.version, k3)
+ }
+ })
+ }
+}
+
+func TestACPAgentInfoVersion(t *testing.T) {
+ t.Parallel()
+ tests := []struct {
+ name string
+ raw string
+ want string
+ }{
+ {name: "kimi shape", raw: `{"protocolVersion":1,"agentInfo":{"name":"Kimi Code CLI","version":"0.33.0"}}`, want: "0.33.0"},
+ {name: "snake_case", raw: `{"agent_info":{"version":"0.29.0"}}`, want: "0.29.0"},
+ {name: "padded", raw: `{"agentInfo":{"version":" 0.30.1 "}}`, want: "0.30.1"},
+ {name: "absent", raw: `{"protocolVersion":1,"agentCapabilities":{}}`, want: ""},
+ {name: "malformed json", raw: `not json`, want: ""},
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ t.Parallel()
+ if got := acpAgentInfoVersion([]byte(tt.raw)); got != tt.want {
+ t.Errorf("acpAgentInfoVersion(%s) = %q, want %q", tt.raw, got, tt.want)
+ }
+ })
+ }
+}
+
+func TestKimiSupportsThinkingEfforts(t *testing.T) {
+ t.Parallel()
+ tests := []struct {
+ version string
+ want bool
+ }{
+ {version: "0.29.0", want: true}, // first effort-capable build
+ {version: "0.28.1", want: false}, // confirms "on" for any effort
+ {version: "0.33.0", want: true},
+ {version: "1.0.0", want: true},
+ {version: "0.9.0", want: false}, // minor is compared numerically, not lexically
+ {version: "", want: false}, // agent reported no version
+ {version: "not-a-version", want: false},
+ }
+ for _, tt := range tests {
+ t.Run(tt.version, func(t *testing.T) {
+ t.Parallel()
+ if got := kimiSupportsThinkingEfforts(tt.version); got != tt.want {
+ t.Errorf("kimiSupportsThinkingEfforts(%q) = %v, want %v", tt.version, got, tt.want)
+ }
+ })
+ }
+}
+
+func thinkingValues(thinking *ModelThinking) []string {
+ if thinking == nil {
+ return nil
+ }
+ values := make([]string, 0, len(thinking.SupportedLevels))
+ for _, level := range thinking.SupportedLevels {
+ values = append(values, level.Value)
+ }
+ return values
+}
+
func TestClaudeStaticModelsExposesFable5(t *testing.T) {
models := claudeStaticModels()
ids := map[string]Model{}
diff --git a/server/pkg/agent/thinking.go b/server/pkg/agent/thinking.go
index f2ff462add..a219bf6ff8 100644
--- a/server/pkg/agent/thinking.go
+++ b/server/pkg/agent/thinking.go
@@ -11,8 +11,9 @@ import (
)
// thinking.go discovers per-model reasoning/effort catalogs for the
-// claude, codex, opencode, and pi backends so the daemon can advertise them to
-// the UI without hard-coding (and getting wrong) what's installed locally.
+// claude, codex, opencode, pi, and kimi backends so the daemon can advertise
+// them to the UI without hard-coding (and getting wrong) what's installed
+// locally.
//
// MUL-2339: we deliberately do not flatten Claude's `low|medium|high|
// xhigh|max` and Codex's `none|minimal|low|medium|high|xhigh|max|ultra`
@@ -780,6 +781,7 @@ var providerThinkingEnums = map[string]map[string]bool{
var thinkingDynamicCatalogProviders = map[string]bool{
"codex": true,
"opencode": true,
+ "kimi": true,
}
// ThinkingControlSupported reports whether Multica can deliver a per-agent
@@ -817,8 +819,9 @@ func ThinkingControlSupported(providerType string) bool {
// IsKnownThinkingValue reports whether `value` is a recognised effort
// token for the given provider. Empty string is always accepted (means
// "use runtime default"). Providers with no reasoning control accept
-// only empty; Codex and OpenCode accept well-formed tokens here because their
-// daemon-local catalogs perform the exact per-model check before execution.
+// only empty; Codex, OpenCode, and Kimi accept well-formed tokens here because
+// their daemon-local catalogs perform the exact per-model check before
+// execution.
//
// This is the cheap synchronous gate the server uses on CreateAgent /
// UpdateAgent. Unlike ValidateThinkingLevel it does NOT consult the live
diff --git a/server/pkg/agent/thinking_test.go b/server/pkg/agent/thinking_test.go
index a4fd865ba9..57cbd18203 100644
--- a/server/pkg/agent/thinking_test.go
+++ b/server/pkg/agent/thinking_test.go
@@ -473,6 +473,12 @@ func TestIsKnownThinkingValue(t *testing.T) {
{"pi", "max", true},
{"pi", "ultra", false},
{"pi", "future-level", false},
+ {"kimi", "", true},
+ {"kimi", "low", true},
+ {"kimi", "max", true},
+ {"kimi", "future-level", true}, // exact support is checked against the daemon catalog
+ {"kimi", ".hidden", false},
+ {"kimi", "bad value", false},
{"hermes", "", true},
{"hermes", "low", false}, // hermes' ACP surface exposes no effort dial
{"grok", "", true},
@@ -509,7 +515,7 @@ func TestThinkingControlSupported(t *testing.T) {
{"opencode", true}, // dynamic variant names from opencode.json
{"pi", true}, // fixed tokens, per-model subset discovered over RPC
{"hermes", false}, // ACP adapter drops reasoning entirely (MUL-5770)
- {"kimi", false},
+ {"kimi", true}, // dynamic catalog; ACP session/set_config_option applies it
{"qwenpaw", false},
{"", false},
{"not-a-runtime", false},