Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

feat(harness): add the kimi_code canonical name

Claude59a2b24881aa
diff --git a/pkg/asymptoteobserve/harness.go b/pkg/asymptoteobserve/harness.go
index 2c95447d..afb589af 100644
--- a/pkg/asymptoteobserve/harness.go
+++ b/pkg/asymptoteobserve/harness.go
@@ -347,6 +347,47 @@ func NormalizeHarnessName(name string) string {
lower == "deepseek_ai/dsh" || lower == "deepseek-ai/dsh" ||
lower == "@deepseek-ai/dsh" || lower == "deepseek_dsh" || lower == "deepseek-dsh":
return "deepseek_harness"
+ // Kimi Code (Moonshot AI) is one agent core behind several front ends -- the terminal CLI, the
+ // desktop app, the VS Code extension and the ACP server -- and all of them report the same
+ // client identity to a hook (`client_type: "kimi_code_cli"`), because the identity names the
+ // core rather than the window it is drawn in. So there is one runtime to name, not four, and
+ // the canonical spelling is `kimi_code`: it is the product's name and follows claude_code,
+ // qwen_code and muse_code rather than a CLI suffix that would describe only one surface.
+ //
+ // Equality against a closed set rather than Contains(lower, "kimi"), and this runtime needs it
+ // for three separate reasons at once -- more than any other case in this function:
+ //
+ // - The model family. Every Kimi model id begins with the letters the harness does:
+ // kimi-k2, kimi-k3, kimi-k2.7-code, kimi-latest, kimi-thinking, kimi-for-coding. That is
+ // the Qwen, Muse Spark and OpenHands LM hazard, and here the catalog is large and still
+ // growing.
+ // - The provider. `kimi` is a provider *type* in the runtime's own config.toml
+ // (`[providers.kimi]`, `type = "kimi"`, `KIMI_API_KEY`), so the string names an API route
+ // that other runtimes use too -- a Claude Code session pointed at Moonshot is not a Kimi
+ // Code session.
+ // - The vendor's other surfaces. `kimi.com` is the consumer chat product, which Beacon does
+ // not observe at all; reporting it as the coding agent would invent an endpoint install.
+ //
+ // Bare `kimi` is nonetheless IN the set, unlike bare `deepseek` above, and the difference is
+ // worth stating because the two cases look identical from a distance. It is the `--platform`
+ // value Beacon's own installer writes -- the binary is `kimi`, and the flag follows the binary
+ // the way `muse`, `qwen` and `kiro` do -- so leaving it out would mean every hook Beacon
+ // installs reports a name this function refuses to canonicalize. The three hazards above are
+ // all handled by equality rather than by exclusion: no model id is exactly "kimi", and the
+ // provider type and the chat product reach harness.name by no path that exists today, because
+ // Kimi Code exports no OpenTelemetry and the only writer is the flag Beacon wrote itself.
+ // `deepseek` is out of its set for the opposite reason -- `dsh`, not `deepseek`, is that
+ // runtime's flag, so excluding the vendor word costs nothing there and costs the whole
+ // integration here.
+ //
+ // Model spellings are deliberately absent, so they fall to the passthrough case and show up as
+ // themselves -- a visible anomaly a person can act on rather than a silent misattribution.
+ case lower == "kimi" || lower == "kimi_code" || lower == "kimi-code" || lower == "kimi code" ||
+ lower == "kimicode" || lower == "kimi_cli" || lower == "kimi-cli" || lower == "kimi cli" ||
+ lower == "kimi_code_cli" || lower == "kimi-code-cli" || lower == "kimi code cli" ||
+ lower == "kimi_code_acp" || lower == "kimi-code-acp" ||
+ lower == "moonshot_kimi_code" || lower == "moonshot-kimi-code":
+ return "kimi_code"
case name != "":
// An unrecognized runtime keeps its own name rather than being coerced or dropped. A new
// harness should show up in the log as itself, not as "unknown".
diff --git a/pkg/asymptoteobserve/harness_test.go b/pkg/asymptoteobserve/harness_test.go
index 2df47b10..bc52ebaf 100644
--- a/pkg/asymptoteobserve/harness_test.go
+++ b/pkg/asymptoteobserve/harness_test.go
@@ -25,6 +25,7 @@ func TestHookPlatformsConvergeOnCanonicalNames(t *testing.T) {
"muse": "muse_code",
"goose": "goose",
"dsh": "deepseek_harness",
+ "kimi": "kimi_code",
} {
t.Run(platform, func(t *testing.T) {
if got := NormalizeHarnessName(platform); got != want {
@@ -44,7 +45,7 @@ func TestCanonicalNamesAreStableUnderRenormalization(t *testing.T) {
"claude_code", "codex_cli", "codex_desktop", "gemini_cli", "antigravity_cli", "vscode_copilot",
"copilot_cli", "claude_web", "chatgpt_web", "claude_cowork", "claude_agent_sdk",
"openclaw_gateway", "pi_cli", "omp", "cline", "qwen_code", "prime_agent", "omo_senpi", "vercel_fx",
- "muse_code", "grok_bot", "goose",
+ "muse_code", "grok_bot", "goose", "deepseek_harness", "kimi_code",
} {
t.Run(canonical, func(t *testing.T) {
if got := NormalizeHarnessName(canonical); got != canonical {
@@ -830,3 +831,95 @@ func TestDeepSeekHarnessIsStableUnderRenormalization(t *testing.T) {
t.Fatalf("NormalizeHarnessName(%q) = %q; the canonical name must be stable", once, twice)
}
}
+
+func TestKimiCodeSpellingsConvergeOnKimiCode(t *testing.T) {
+ for _, in := range []string{
+ "kimi", "Kimi", " kimi ", "KIMI",
+ "kimi_code", "kimi-code", "Kimi Code", "kimicode",
+ "kimi_cli", "kimi-cli", "Kimi CLI",
+ "kimi_code_cli", "kimi-code-cli", "Kimi Code CLI",
+ "kimi_code_acp", "kimi-code-acp",
+ "moonshot_kimi_code", "moonshot-kimi-code",
+ } {
+ t.Run(in, func(t *testing.T) {
+ if got := NormalizeHarnessName(in); got != "kimi_code" {
+ t.Errorf("NormalizeHarnessName(%q) = %q, want %q", in, got, "kimi_code")
+ }
+ })
+ }
+}
+
+// `kimi_code_cli` is the literal `client_type` Kimi Code stamps on every hook payload, from the
+// terminal CLI, the desktop app, the VS Code extension and the ACP server alike. It has to land on
+// the same harness as the `--platform kimi` flag Beacon's installer writes, or one session is
+// recorded under two names depending on which field a future reader picks up.
+func TestKimiClientTypeAndInstallerFlagAgree(t *testing.T) {
+ fromFlag := NormalizeHarnessName("kimi")
+ fromClientType := NormalizeHarnessName("kimi_code_cli")
+ if fromFlag != fromClientType {
+ t.Fatalf("NormalizeHarnessName(\"kimi\") = %q but NormalizeHarnessName(\"kimi_code_cli\") = %q; "+
+ "the installer flag and the runtime's own client identity must resolve to one harness",
+ fromFlag, fromClientType)
+ }
+}
+
+// The first reason the Kimi Code case is an equality match rather than a Contains rule. Moonshot
+// ships the agent and a large, growing model family under one name, so every Kimi model id begins
+// with the letters the harness does. A substring rule would report any event whose harness
+// attribute happened to carry one of those model strings as a Kimi Code session, and a reader
+// could not tell the misattribution from the real thing because both start with the same word.
+func TestKimiModelSpellingsAreNotTheKimiCodeHarness(t *testing.T) {
+ for _, name := range []string{
+ "kimi-k2", "kimi-k3", "kimi-k2.5", "kimi-k2.6", "kimi-k2.7-code",
+ "kimi-k2-thinking", "kimi-k2-0905-preview", "kimi-k3-fast", "kimi-latest",
+ "kimi-thinking", "kimi-for-coding", "moonshotai/kimi-k2.5", "moonshot-kimi-k2-instruct",
+ } {
+ t.Run(name, func(t *testing.T) {
+ if got := NormalizeHarnessName(name); got == "kimi_code" {
+ t.Errorf("NormalizeHarnessName(%q) = %q; a Kimi model id must not be reported as "+
+ "the Kimi Code runtime", name, got)
+ }
+ })
+ }
+}
+
+// The second and third reasons. `kimi` is also a provider type inside Kimi Code's own config.toml
+// -- one that Claude Code, Codex and other runtimes point at too -- and `kimi.com` is the consumer
+// chat product Beacon does not observe at all. A name that merely mentions either must not be
+// filed as an endpoint install of the coding agent.
+func TestNamesMerelyMentioningKimiAreNotTheKimiCodeHarness(t *testing.T) {
+ for _, name := range []string{
+ "kimi.com", "KIMI_API_KEY", "providers.kimi", "kimi_provider", "kimi-webbridge",
+ "~/.kimi-code", "KIMI_CODE_HOME", "kimikaze", "akimi",
+ } {
+ t.Run(name, func(t *testing.T) {
+ if got := NormalizeHarnessName(name); got == "kimi_code" {
+ t.Errorf("NormalizeHarnessName(%q) = %q; a name merely mentioning \"kimi\" must not "+
+ "be reported as the Kimi Code runtime", name, got)
+ }
+ })
+ }
+}
+
+// Kimi Code is not Claude Code, and the generic `strings.Contains(lower, "claude")` rule sits well
+// above this case. Kimi Code can be configured with an `anthropic` provider and can be driven
+// through Anthropic-shaped endpoints, so a name that mentions both vendors is a real possibility;
+// what must never happen is a bare Kimi spelling resolving to claude_code.
+func TestKimiCodeIsNotAttributedToClaudeCode(t *testing.T) {
+ for _, name := range []string{"kimi", "kimi_code", "kimi-code-cli"} {
+ t.Run(name, func(t *testing.T) {
+ if got := NormalizeHarnessName(name); got == "claude_code" {
+ t.Errorf("NormalizeHarnessName(%q) = %q; Kimi Code is a separate runtime from "+
+ "Claude Code", name, got)
+ }
+ })
+ }
+}
+
+// A name that has been through the function once must not change meaning going through again.
+func TestKimiCodeIsStableUnderRenormalization(t *testing.T) {
+ once := NormalizeHarnessName("kimi")
+ if twice := NormalizeHarnessName(once); twice != once {
+ t.Fatalf("NormalizeHarnessName(%q) = %q; the canonical name must be stable", once, twice)
+ }
+}
diff --git a/pkg/asymptoteobserve/provenance_test.go b/pkg/asymptoteobserve/provenance_test.go
index f65d8bd0..06cd4891 100644
--- a/pkg/asymptoteobserve/provenance_test.go
+++ b/pkg/asymptoteobserve/provenance_test.go
@@ -134,6 +134,14 @@ func TestCollectionMethodForPlatform(t *testing.T) {
// runtime loads (opencode, Cline, Pi, Oh My Pi), and claiming it here would send someone to
// fix Beacon for a field the bridge never sent.
"dsh": CollectionMethodHook,
+ // Kimi Code is hook-shaped. The `[[hooks]]` array, the event names and the payload shapes
+ // are all Moonshot's, and Beacon only appends command entries to a config file the runtime
+ // already reads -- it ships no source the runtime loads. Kimi Code also has a plugin system
+ // that can declare hooks, which is the thing that makes this worth stating: Beacon
+ // deliberately does not use it, because a plugin install needs an interactive step and a
+ // `/reload`, and choosing it would have changed this field as a side effect of an install
+ // mechanic rather than of what runs on each event.
+ "kimi": CollectionMethodHook,
// vscode is the case that justifies keying on --platform rather than on the normalized
// harness name: its hook and OTLP telemetry both normalize to vscode_copilot, so the
// harness name cannot distinguish them and only the flag can.