provider: a group of Kimi models keeps always_thinking, dynamic tools and its default effort
jiabubu on Discord (#feedback): one Kimi Code model put in a routing group so it lists first lost "always thinking" and "dynamic tool loading" in Kimi Code, which the same model straight from its provider has. buildGroupEntries never set AlwaysThinks, DynamicTools or DefaultEffort on a group (the Entry comment said "a group has none of them"), so kimiModelTables wrote the group's table without always_thinking and dynamically_loaded_tools, and default_effort fell back to high. groupSharedKimi now gives a group each of the three when every member's entry says the same, and none of it when one member doesn't or has no entry: a group request can reach any member (rule targets are members too, ruledEntry's of()), so Kimi Code must not shape a request for a member that can't take it. The capability words are Kimi Code 2.4.1's own (catalog-runtime.ts capabilityFromDeclared), already written for direct models; kimi-cli still gets neither. Tests: TestGroupSharesKimiFacts (provider: all share, one without, efforts differ) and TestKimiCodePlanCapabilities now writes a one-member group "top" (the reporter's case: always_thinking, dynamically_loaded_tools, default_effort max) and a group "mix" with a relay model (neither word). Run on mote (mote-run, sandbox HOME): - At 83a630d69 (onfbb1b36d1): gofmt -l internal/provider internal/agent clean; go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... ok; go test -tags nogui -count=1 -timeout 45m ./...: every package ok but internal/gui TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and internal/proc TestNoCommandBypassesProc (#4491). Both fail the same at origin/main841326709, just fetched; neither touches this change. - At the pushed head (rebased on841326709): go test -count=1 -timeout 45m ./internal/provider ./internal/agent ./internal/catalog ok. Broken by hand: without the groupSharedKimi call, both tests go red (group/top loses always_thinking and dynamically_loaded_tools and gets high). With "any member" instead of "every member", both go red (group/mix and the mixed auto groups get the words). Not tried: a real Kimi Code session picking the group (the words are the ones real Kimi Code 2.4.1 already reads for direct models), Windows and Linux test runs (vet only), nested groups.
This commit is contained in:
@@ -62,7 +62,7 @@ something else shows up as drift.
|
||||
- Hermes's `api_key` may be a reference, `${VAR}` or `${env:VAR}`, which Hermes expands from the `.env` beside the config (its own or a profile's) and then the environment. `Check` and a sync read the key it names (`hermesKey`): one that holds (`keyHolds`) stays and isn't drift, and so does one naming a variable magpie can't see (only a shell profile sets it), which is unknown. One naming a key the gateway doesn't take is drift, and a sync keeps the reference and writes magpie's key into that `.env` under the variable, made `0600` when there is none (`hermesKeptKey`; PaulT on Discord, `TestHermesWithAKeyInItsEnvFile`). A value with more than the one reference in it is replaced by magpie's key, as before.
|
||||
- omp's `models.yml` keeps `modelOverrides`, `discovery`, `disableStrictTools`, headers and compat flags (`ompKept`). Its `auth` and `apiKey` are magpie's, or gone.
|
||||
- Kimi Code's `[providers.magpie]` has magpie's three keys set in place, so `custom_headers`, `env` and `default_model` stay (`kimiProvider`).
|
||||
- A Kimi Code model table says what Kimi's own list (`/coding/v1/models`) says of the model, as Kimi Code's own provider does (`capabilitiesForModel` in its `managed-kimi-code.ts`): `always_thinking` for `supports_thinking_type` "only", `dynamically_loaded_tools` for `supports_dynamic_tools`, and `default_effort` at its `think_efforts.default_effort` (max on K2.8 Preview), else high (`kimiModelTables`, `kimiFacts`; `TestKimiCodePlanCapabilities`). kimi-cli gets neither word. `video_in` is never written: Kimi Code uploads a video to its provider's `/files`, which the gateway has no route for (#4485). A `default_effort` the user set stays while the model has it; one magpie wrote is recorded in the stash (`kimiWroteKey`), and an unrecorded high is read as the one magpie wrote before it kept a record.
|
||||
- A Kimi Code model table says what Kimi's own list (`/coding/v1/models`) says of the model, as Kimi Code's own provider does (`capabilitiesForModel` in its `managed-kimi-code.ts`): `always_thinking` for `supports_thinking_type` "only", `dynamically_loaded_tools` for `supports_dynamic_tools`, and `default_effort` at its `think_efforts.default_effort` (max on K2.8 Preview), else high (`kimiModelTables`, `kimiFacts`; `TestKimiCodePlanCapabilities`). A routing group says each of the three when every member's entry says the same, and none of it when one member doesn't (`groupSharedKimi`; `TestGroupSharesKimiFacts`). kimi-cli gets neither word. `video_in` is never written: Kimi Code uploads a video to its provider's `/files`, which the gateway has no route for (#4485). A `default_effort` the user set stays while the model has it; one magpie wrote is recorded in the stash (`kimiWroteKey`), and an unrecorded high is read as the one magpie wrote before it kept a record.
|
||||
- Cline's `models.json` keeps the provider's other keys, and on each model magpie lists what magpie doesn't write, such as a VS Code override (`clineKept`).
|
||||
- VS Code's, Insiders' and VSCodium's group in `chatLanguageModels.json` (each profile's too) keeps every key magpie doesn't write, such as `settings["<model id>"].reasoningEffort`, which VS Code writes there when the user picks an effort in Copilot Chat's model picker (`setModelConfiguration`); a whole rewrite on each Sync and pick sent the model at its first level (chim3744 on Discord). A model's settings stay after it leaves the catalog; the model list is magpie's (`vscodeGroupKept`, `TestVSCodeKeepsThePickedEffort`).
|
||||
- Goose's custom provider file keeps a name, `timeout_seconds`, `toolshim`, headers and the like (`gooseProviderKept`).
|
||||
|
||||
@@ -67,6 +67,14 @@ func TestKimiCodePlanCapabilities(t *testing.T) {
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// jiabubu again: one Kimi model put in a group so it lists first keeps
|
||||
// what its list says; a group with another vendor's model has none
|
||||
if err := provider.SaveGroup(provider.Group{ID: "top", Name: "Top", Members: []string{"kimi-code-cn/kimi-for-coding"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := provider.SaveGroup(provider.Group{ID: "mix", Name: "Mix", Members: []string{"kimi-code-cn/kimi-for-coding", "relay/gemini-3-pro"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
type model struct {
|
||||
Capabilities []string `toml:"capabilities"`
|
||||
@@ -99,6 +107,9 @@ func TestKimiCodePlanCapabilities(t *testing.T) {
|
||||
[]string{"low", "high", "max"}, "high"},
|
||||
// another vendor's model, video and all, as it was
|
||||
"magpie/relay/gemini-3-pro": {[]string{"thinking", "image_in", "tool_use"}, []string{"low", "high"}, "high"},
|
||||
"magpie/group/top": {[]string{"thinking", "always_thinking", "image_in", "tool_use", "dynamically_loaded_tools"},
|
||||
[]string{"low", "high", "max"}, "max"},
|
||||
"magpie/group/mix": {[]string{"thinking", "image_in", "tool_use"}, []string{"low", "high"}, "high"},
|
||||
}
|
||||
got := read(path)
|
||||
for k, w := range want {
|
||||
|
||||
@@ -1073,6 +1073,33 @@ func entriesBy(entries []Entry) entryOf {
|
||||
}
|
||||
}
|
||||
|
||||
// groupSharedKimi gives a group what the providers' lists say of a model
|
||||
// (AlwaysThinks, DynamicTools, DefaultEffort) when every member's entry
|
||||
// says the same: a group of Kimi Code's models keeps always_thinking and
|
||||
// dynamically_loaded_tools in Kimi Code (jiabubu on Discord: one Kimi
|
||||
// model put in a group to list it first lost both). One member without it,
|
||||
// or one magpie has no entry for, and the group has none: Kimi Code would
|
||||
// send a member that can't the request shaped for one that can
|
||||
func groupSharedKimi(e *Entry, ms []Member, entries []Entry, find entryOf) {
|
||||
for i, m := range ms {
|
||||
j := find(m.Provider.ID, m.Model)
|
||||
if j < 0 {
|
||||
e.AlwaysThinks, e.DynamicTools, e.DefaultEffort = false, false, ""
|
||||
return
|
||||
}
|
||||
x := &entries[j]
|
||||
if i == 0 {
|
||||
e.AlwaysThinks, e.DynamicTools, e.DefaultEffort = x.AlwaysThinks, x.DynamicTools, x.DefaultEffort
|
||||
continue
|
||||
}
|
||||
e.AlwaysThinks = e.AlwaysThinks && x.AlwaysThinks
|
||||
e.DynamicTools = e.DynamicTools && x.DynamicTools
|
||||
if e.DefaultEffort != x.DefaultEffort {
|
||||
e.DefaultEffort = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func buildGroupEntries(entries []Entry) []Entry {
|
||||
var out []Entry
|
||||
all := groupsIn(entries)
|
||||
@@ -1220,6 +1247,7 @@ func buildGroupEntries(entries []Entry) []Entry {
|
||||
// V2 for Ultra only when no member is a ChatGPT account's: a lead
|
||||
// it answers seals its subagents' tasks (#141)
|
||||
e.AgentsV2 = !chatgpt && slices.Contains(e.Efforts, "ultra")
|
||||
groupSharedKimi(&e, ms, entries, find)
|
||||
e.Reasoning = e.Reasoning || len(e.Efforts) > 0
|
||||
if e.ImageInput != nil && !*e.ImageInput {
|
||||
e.Images = false
|
||||
|
||||
@@ -103,3 +103,38 @@ func TestCodexListedKeepsGroups(t *testing.T) {
|
||||
t.Errorf("fast: group %v, model %v", ms[0].Fast, ms[1].Fast)
|
||||
}
|
||||
}
|
||||
|
||||
// A group keeps what Kimi Code's list says of its models (always thinks,
|
||||
// loads tools mid-conversation, its default effort) when every member says
|
||||
// it, and has none of it when one member doesn't (jiabubu on Discord: a Kimi
|
||||
// model put in a group lost always_thinking and dynamically_loaded_tools in
|
||||
// Kimi Code).
|
||||
func TestGroupSharesKimiFacts(t *testing.T) {
|
||||
t.Setenv("HOME", t.TempDir())
|
||||
t.Setenv("USERPROFILE", t.TempDir())
|
||||
t.Setenv("XDG_CONFIG_HOME", "")
|
||||
e := func(p, m string, always, dynamic bool, def string) Entry {
|
||||
return Entry{ID: p + "/" + m, Model: m, Name: m, Provider: Provider{ID: p}, Reasoning: true,
|
||||
Efforts: []string{"low", "medium", "high"}, AlwaysThinks: always, DynamicTools: dynamic, DefaultEffort: def}
|
||||
}
|
||||
type facts struct {
|
||||
always, dynamic bool
|
||||
def string
|
||||
}
|
||||
got := map[string]facts{}
|
||||
for _, g := range groupEntries([]Entry{
|
||||
e("kimi-code", "kimi-k3", true, true, "high"), e("kimi-code-cn", "kimi-k3", true, true, "high"),
|
||||
e("kimi-code", "kimi-k2.7", true, true, "high"), e("or", "kimi-k2.7", false, false, ""),
|
||||
e("kimi-code", "kimi-k2.8", true, false, "medium"), e("kimi-code-cn", "kimi-k2.8", true, true, "high"),
|
||||
}) {
|
||||
got[g.ID] = facts{g.AlwaysThinks, g.DynamicTools, g.DefaultEffort}
|
||||
}
|
||||
want := map[string]facts{
|
||||
AutoPrefix + "kimi-k3": {true, true, "high"},
|
||||
AutoPrefix + "kimi-k2.7": {},
|
||||
AutoPrefix + "kimi-k2.8": {always: true},
|
||||
}
|
||||
if !maps.Equal(got, want) {
|
||||
t.Errorf("got %+v, want %+v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2648,8 +2648,8 @@ type Entry struct {
|
||||
// AlwaysThinks, DynamicTools and DefaultEffort are what the provider's
|
||||
// own list says of the model (catalog.Model's): it always thinks, it
|
||||
// loads tools mid-conversation, it thinks at this effort unasked.
|
||||
// Kimi Code's list says them, and Kimi Code is told them (a group
|
||||
// has none of them)
|
||||
// Kimi Code's list says them, and Kimi Code is told them. A group
|
||||
// has each one its members all share (groupSharedKimi)
|
||||
AlwaysThinks bool `json:"-"`
|
||||
DynamicTools bool `json:"-"`
|
||||
DefaultEffort string `json:"-"`
|
||||
|
||||
Reference in New Issue
Block a user