qwenpaw: each model says how its thinking is set, and the editor sets the level (Pkh)
Pkh (Discord, 0.1.2509 on Linux, QwenPaw 2.2.2.post1): QwenPaw's
thinking strength did nothing on magpie's models.
Cause, from QwenPaw 2.2.2.post1's own source:
- providers/provider.py thinking_control() takes a model's
thinking_control, else its thinking_param_style; with neither it is
ThinkingControl() of kind "unknown".
- providers/thinking.py resolve_thinking drops an unknown control to
inherit, so agent.json's thinking_level was never sent.
- magpie wrote neither key in magpie.json's models, so every magpie
model was "unknown".
Change:
- qwenpawModelJSON writes thinking_param_style "effort" and
reasoning_effort_options for a model whose catalog efforts include
levels QwenPaw names (minimal, low, medium, high, xhigh, max), in
QwenPaw's order. "none" is left out: QwenPaw's off sends
enable_thinking / thinking extra_body, which the gateway strips for
some upstreams.
- Both keys are magpie-owned. A model whose efforts go away has them
taken back. A null magpie writes where it never wrote is dropped,
so a user's own config_overrides are kept.
- The QwenPaw agent editor gets an effort field over agent.json's
thinking_level. "" writes inherit. Setting a level drops
thinking_budget, which QwenPaw's validator requires. A budget or
off level the user set is shown and kept.
- Docs: agent-wiring.md and reference.md.
Run:
- gofmt -l: clean.
- go vet darwin, windows, and linux (-tags nogui): clean (mote).
- go test -timeout 45m ./internal/agent/...: ok (mote).
- go test ./internal/gui: 3 reds, also red on origin/main 8ac1c7a56
and already filed (#4514, #3949, #4510).
- Real QwenPaw 2.2.2.post1 in a sandbox HOME, in WSL magpie-desktop:
- Loaded magpie's generated magpie.json and agent.json with
QwenPaw's own ProviderManager and AgentProfileConfig.
- kimi/k2 resolves to {kind: effort, efforts: [low, medium, high,
max]}.
- A real request to a local capture server carries
reasoning_effort "high" at level high, and none at inherit.
- The old file's model resolves to kind unknown, and sends nothing
at any level.
Broken by hand:
- With the origin qwenpaw.go, both new tests are red.
- Without the thinking_budget delete, TestQwenPawEffortField is red.
- Without the new owned keys, the take-back assertion is red.
Not tried:
- QwenPaw's full app UI against a running magpie gateway.
This commit is contained in:
+1
-1
@@ -129,7 +129,7 @@ line; agents connected to magpie lose it when it quits.
|
||||
| Empryo | `~/.empryo/config.json` | defaultModel (a `magpie` provider at the gateway in `providers`) |
|
||||
| Ante | `~/.ante/catalog.json` and `settings.json` (`$ANTE_HOME`) | provider, model (a `magpie` provider on OpenAiCompatible, with no auth of magpie's: the gateway lets this machine in with any token and Ante counts a provider with none as authenticated; magpie's models in Ante's model picker, and Ante started on magpie, which is what its settings' `provider` decides) |
|
||||
| AstrBot | `data/cmd_config.json` under `$ASTRBOT_ROOT`, else `~/.astrbot` (the desktop app's) | model (a `magpie` entry in `provider_sources` and magpie's models in `provider`, the user's own entries kept; the default chat model in `agent_runner.config.model.provider_id`, or `provider_settings.default_provider_id` on AstrBot before 4.28's agent runner; restart AstrBot after connecting; Docker installs aren't reached) |
|
||||
| QwenPaw | each agent's `agent.json` in its workspace (`~/.qwenpaw/workspaces/<agent>`, the agents listed in `config.json`), under `$QWENPAW_WORKING_DIR`, else a legacy `~/.copaw`, else `~/.qwenpaw` | model (a `magpie` custom provider in `providers/custom/magpie.json` under QwenPaw's secret folder, `$QWENPAW_SECRET_DIR` or `~/.qwenpaw.secret`, OpenAI Chat at the gateway with magpie's models; the agent's `active_model` set to it, what was there put back on Disconnect; one row per agent, `qwenpaw` the default and `qwenpaw#<id>` the others; an agent on an ACP backend isn't listed; restart QwenPaw after the first connect) |
|
||||
| QwenPaw | each agent's `agent.json` in its workspace (`~/.qwenpaw/workspaces/<agent>`, the agents listed in `config.json`), under `$QWENPAW_WORKING_DIR`, else a legacy `~/.copaw`, else `~/.qwenpaw` | model (a `magpie` custom provider in `providers/custom/magpie.json` under QwenPaw's secret folder, `$QWENPAW_SECRET_DIR` or `~/.qwenpaw.secret`, OpenAI Chat at the gateway with magpie's models; the agent's `active_model` set to it, what was there put back on Disconnect; one row per agent, `qwenpaw` the default and `qwenpaw#<id>` the others; an agent on an ACP backend isn't listed; restart QwenPaw after the first connect), effort (the agent's `thinking_level`; magpie's models with reasoning levels are declared `thinking_param_style: "effort"` so QwenPaw applies it) |
|
||||
| OpenClaw | `openclaw.json` in `~/.openclaw` (`$OPENCLAW_CONFIG_PATH`, `$OPENCLAW_STATE_DIR`, `~/.openclaw-<profile>` for `$OPENCLAW_PROFILE`, `~` as `$OPENCLAW_HOME`) | model (a `magpie` provider in `models.providers`, `openai-completions`, with magpie's models in it; `agents.defaults.model`'s primary set to it, what was there put back on Disconnect; `magpie/*` added to a `modelPolicy.allow` that would refuse it; the user's own keys in the provider and its models kept; a chat already on a model keeps it until `/model default`) |
|
||||
| jcode | `config.toml` in `$JCODE_HOME`, else `~/.jcode` | model (a `[providers.magpie]` profile, `openai-compatible`, with magpie's models in it; `[provider] default_provider`/`default_model` set to it, what was there put back on Disconnect; the user's own keys in the profile, such as `headers` and a model's `reasoning_effort`, kept; restart open jcode sessions after connecting) |
|
||||
| MiniMax Code (mcode) | `~/.minimax/config.yaml` (`$MINIMAX_DATA_DIR`) | model (a `magpie` custom provider; magpie's models in its /model) |
|
||||
|
||||
@@ -78,7 +78,7 @@ something else shows up as drift.
|
||||
- While magpie serves, `KeepDshWired` writes the routes again every 30 seconds, since dsh writes over its patch list. A round that writes nothing is kept (`dshRounds`), and the next round does nothing when nothing it reads has changed since. It checks the bytes of dsh's files (every profile's `cordis.patch.yml`, the home layer, `settings.yaml`, `.env`, `.credentials.yaml`, `config.yaml`) and the gateway's address. It also checks `provider.StampNow`: no Changed, plugin change or `filememo.Forget`, the same environment, and the providers', settings' and catalog's files unchanged. The models are built again when that stamp moves, and at least every `dshModelsFor` (5 minutes) for what no stamp sees, such as another app's account file or a date-retired model. Building the whole catalog and every route each round allocated 12 GB of a user's 35.7 GB in 48 minutes (`TestDshRoundWithNothingChangedBuildsNothing`, `TestDshRoundAfterAChangeWritesAgain`).
|
||||
- DeepSeek Harness Desktop (macOS arm64 and Windows x64; no Linux build) reads the same `$DSH_HOME` or `~/.dsh` as the CLI, as its own profile `profiles/desktop` (`resolveDshHome` and `resolveDesktopPaths` in the app's `lib/main.js`; `defaultDshHome` in github.com/deepseek-ai/deepseek-harness's `packages/util/home-paths/src/index.ts` and `apps/desktop/src/paths.ts`), so it takes magpie's routes with no wiring of its own (#2279, liangjinyuan-sihan). Only that app, from deepseek-ai/deepseek-harness (bundle id `com.deepseek.dsh`, productName DeepSeek Harness in `apps/desktop/scripts/electron-builder-config.mjs`), is dsh's: the community "DeepSeek Hermes" (motongv/deepseek-hermes-desktop) v0.1.1337 took for it is not listed or written for (WuSix on Discord, `TestDshOnlyTheOfficialApp`). It is found by `/Applications/DeepSeek Harness.app`, by `%LOCALAPPDATA%\Programs\DeepSeek Harness`, or by the folder its current-user installer records under `HKCU\Software\1bf39983-50d0-5fe0-9ef4-cece76f67c5e` (`InstallLocation`), whose Uninstall key gives the version (`registered` in [`desktopapp.go`](../../internal/agent/desktopapp.go)), so a user who picked another folder is found. With the app installed but never opened there is no `~/.dsh`: the row is still listed, and connecting writes `profiles/desktop/cordis.patch.yml` from dsh's own template (`dshProfileTemplate`) with magpie's routes, which the app keeps on its first start, since it writes only the files that are missing. The notice says the app starts on it the first time it opens (`noticeDsh5`). Disconnect before that first start removes the profile magpie made when nothing else is in it (`dshTidyUnopened`); once the app has opened it, the profile stays and only magpie's entries go (`TestDshDesktopNeverOpened`, `TestDshDesktopRegisteredFolder`; the registry as 0.2.1-rc.2's installer writes it, `TestDshWindowsAsTheInstallerRegistersIt`).
|
||||
- Ante's `catalog.json` keeps user-added fields in `providers.magpie` the same way (`ante` in [`ante.go`](../../internal/agent/ante.go)); its `auth`, `http_headers`, `extra_body` and `stream_idle_timeout_secs` are what a gateway shared on the local network or reached from WSL needs to send a key. Ante starts a session on the `provider` and `model` of `settings.json`, not on what its catalog holds (#1210), so magpie sets that pair and puts back what it found there; a pick the user makes in Ante while magpie is wired is theirs and stands.
|
||||
- QwenPaw keeps each agent's model in `active_model` of its workspace's `agent.json` (the agents listed in `config.json` under `$QWENPAW_WORKING_DIR`, a legacy `~/.copaw`, or `~/.qwenpaw`) and its providers as files under its secret folder (`$QWENPAW_SECRET_DIR`, also read from the working folder's `.env`, else `<working folder>.secret`) (`qwenpaw` and `qwenpawAgents` in [`qwenpaw.go`](../../internal/agent/qwenpaw.go)). magpie writes `providers/custom/magpie.json` as QwenPaw's console saves a custom provider (OpenAI Chat at the gateway's `/v1`, the key in plain text, which QwenPaw encrypts at its next start, magpie's models in `extra_models`), keeps what the user changes there (a model's `config_overrides`, headers, generation settings), and sets the agent's `active_model` to `magpie`/`<provider>/<model>`, putting back what it found there. Each QwenPaw agent on QwenPaw's own backend is a row (`qwenpaw#<id>` beside the default's `qwenpaw`); the provider file goes when no agent's model, fallback or subagent model names it. QwenPaw reads `agent.json` again when it changes but its providers only at start-up, so the notice says to restart it after the first connect.
|
||||
- QwenPaw keeps each agent's model in `active_model` of its workspace's `agent.json` (the agents listed in `config.json` under `$QWENPAW_WORKING_DIR`, a legacy `~/.copaw`, or `~/.qwenpaw`) and its providers as files under its secret folder (`$QWENPAW_SECRET_DIR`, also read from the working folder's `.env`, else `<working folder>.secret`) (`qwenpaw` and `qwenpawAgents` in [`qwenpaw.go`](../../internal/agent/qwenpaw.go)). magpie writes `providers/custom/magpie.json` as QwenPaw's console saves a custom provider (OpenAI Chat at the gateway's `/v1`, the key in plain text, which QwenPaw encrypts at its next start, magpie's models in `extra_models`), keeps what the user changes there (a model's `config_overrides`, headers, generation settings), and sets the agent's `active_model` to `magpie`/`<provider>/<model>`, putting back what it found there. A model with reasoning levels is declared `thinking_param_style: "effort"` with the levels QwenPaw names in `reasoning_effort_options` (no `none`: QwenPaw turns an off into Qwen's and DeepSeek's `extra_body` switches), since QwenPaw applies an agent's `thinking_level` only to a model whose card says how it thinks; the effort field is that `thinking_level` in `agent.json`, written with no `thinking_budget`, `inherit` when cleared. Each QwenPaw agent on QwenPaw's own backend is a row (`qwenpaw#<id>` beside the default's `qwenpaw`); the provider file goes when no agent's model, fallback or subagent model names it. QwenPaw reads `agent.json` again when it changes but its providers only at start-up, so the notice says to restart it after the first connect.
|
||||
- AstrBot keeps its providers in `data/cmd_config.json` under its root (`$ASTRBOT_ROOT`, else `~/.astrbot`, the desktop app's, else `~/astrbot`), written with a UTF-8 BOM, which magpie keeps (`astrbot` in [`astrbot.go`](../../internal/agent/astrbot.go)). magpie adds a `magpie` entry to `provider_sources` and one `magpie/<model>` entry per model to `provider`, keeps the user's own entries byte for byte and keeps what the user changes in magpie's (timeout, proxy, enable), and sets the default chat model (`agent_runner.config.model.provider_id`, or `provider_settings.default_provider_id` before the agent runner), putting back what it found there. A pick the user makes while magpie is wired is theirs and stands. The first connect copies the file to `cmd_config.json.before-magpie`. AstrBot reads the file only at start-up and its WebUI writes it back whole on save, so the agent's notice says to restart AstrBot before saving in the WebUI. A Docker install's root is inside its container, which magpie doesn't reach.
|
||||
- OpenClaw keeps its settings in `openclaw.json` (`openClaw` in [`openclaw.go`](../../internal/agent/openclaw.go)), found as OpenClaw's own `resolveConfigPath` and `resolveStateDir` find it: `$OPENCLAW_CONFIG_PATH`, else in `$OPENCLAW_STATE_DIR`, else in `~/.openclaw-<profile>` for a named `$OPENCLAW_PROFILE`, else in `~/.openclaw`, `~` being `$OPENCLAW_HOME` when set. magpie adds the provider `models.providers.magpie` as OpenClaw's schema has one (`zod-schema.core.ts`, strict, so only keys it knows): `baseUrl` at the gateway's `/v1`, `apiKey` naming OpenClaw, `api: openai-completions`, and one model per catalog model with `id`, `name`, `input` (`image` for a model that takes images), `reasoning` for a model with effort levels, and `contextWindow`. The model OpenClaw runs on is `agents.defaults.model`: a string stays a string, an object gets its `primary` set and keeps its `fallbacks`, and the ref is added to `agents.defaults.models` as `openclaw models set` adds it. A non-empty `agents.defaults.modelPolicy.allow` with nothing of magpie's gets `magpie/*`. What the model was is stashed and put back on Disconnect, while magpie's is still the primary; the `magpie/*` and the `{}` entries magpie added go, and so do objects magpie made and the file if magpie made it. The user's own keys stay, in magpie's provider and in a model entry of the same id too, and a sync with nothing to change doesn't write. The file is read as JSON with comments; a JSON5 file (bare keys), which OpenClaw also reads, is left alone and Check says so. A new file is made 0600 in a 0700 folder, as OpenClaw makes its own. OpenClaw's gateway takes the change without a restart, but a chat already on a model keeps it, so the notice says to send `/model default` there. A per-agent model (`agents.entries.*.model`) and a config split with `$include` are left to the user.
|
||||
- jcode keeps its settings in `config.toml` in `$JCODE_HOME`, else `~/.jcode` (`jcode` in [`jcode.go`](../../internal/agent/jcode.go)). magpie adds a named profile, `[providers.magpie]`, as `jcode provider add` writes one: `type = "openai-compatible"`, the gateway's `/v1`, an inline `api_key` naming jcode (jcode sends nothing else that tells it apart) and `requires_api_key = true`, since jcode sends no key to a loopback URL without it. Its `models` list has one entry per model, with `context_window`, `input` and `reasoning` for a model with effort levels. A `reasoning_effort` the user set on one stays while the model has that level. The model jcode starts on is `[provider] default_provider = "magpie"` and `default_model`. What was there is stashed and put back on Disconnect. A model of jcode's own picked while it is on magpie takes magpie out. Each key is set alone, so the user's other keys and tables stay, and the `[[providers.magpie.models]]` tables jcode writes when it saves the file itself are replaced by the one list. A sync with nothing to change doesn't write. Disconnect drops the profile whole, its sub-tables included. jcode reads the file when it starts, so the notice says to restart open sessions.
|
||||
|
||||
@@ -14,10 +14,11 @@ package agent
|
||||
//
|
||||
// "active_model": {"provider_id": "…", "model": "…"}
|
||||
//
|
||||
// beside fallback_models, subagent_model and thinking_level, which magpie
|
||||
// leaves alone. Only an agent whose backend is "qwenpaw" (the default)
|
||||
// runs that model (app/routers/agents.py); one on an ACP backend runs
|
||||
// another program. QwenPaw reads agent.json again when it changes
|
||||
// beside fallback_models and subagent_model, which magpie leaves alone,
|
||||
// and thinking_level, which is the agent's effort field. Only an agent
|
||||
// whose backend is "qwenpaw" (the default) runs that model
|
||||
// (app/routers/agents.py); one on an ACP backend runs another program.
|
||||
// QwenPaw reads agent.json again when it changes
|
||||
// (load_agent_config's fingerprint), and asks for the model on every turn
|
||||
// (agents/model_factory.py create_model_and_formatter), so a model picked
|
||||
// there is used from the next message.
|
||||
@@ -454,6 +455,49 @@ func qwenpawAt(at place, work string, p qwenpawProfile) *Agent {
|
||||
Options: func(cur map[string]string) []Option {
|
||||
return append(qwenpawOwn(providers, cur["model"]), viaMagpie("qwenpaw", magpieID+"/")...)
|
||||
},
|
||||
}, {
|
||||
// the agent's thinking_level (config.py's AgentProfileConfig),
|
||||
// held by QwenPaw to the levels its model's card has; "" is
|
||||
// its inherit, the model's own
|
||||
Key: "effort", Label: "effort",
|
||||
Get: func() string {
|
||||
l := get("thinking_level").String()
|
||||
if l == "inherit" {
|
||||
return ""
|
||||
}
|
||||
return l
|
||||
},
|
||||
Set: func(v string) error {
|
||||
if !isFile(path) {
|
||||
return fmt.Errorf("QwenPaw has no %s yet: start QwenPaw once (qwenpaw app) so it writes its agents' settings", path)
|
||||
}
|
||||
if l := get("thinking_level").String(); v == l && (v == "budget" || v == "off") {
|
||||
return nil
|
||||
}
|
||||
if v != "" && !slices.Contains(qwenpawLevels, v) {
|
||||
return fmt.Errorf("QwenPaw has no thinking level %q", v)
|
||||
}
|
||||
b, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// a budget goes with the budget level alone (config.py's
|
||||
// validate_thinking_budget)
|
||||
out, err := edit.PatchJSON(b, []edit.KV{{Path: "thinking_level", Value: cmp.Or(v, "inherit")}}, []string{"thinking_budget"})
|
||||
if err != nil || bytes.Equal(out, b) {
|
||||
return err
|
||||
}
|
||||
return edit.WriteAtomic(path, out)
|
||||
},
|
||||
Options: func(cur map[string]string) []Option {
|
||||
// no off: magpie's models declare none (qwenpawModelJSON);
|
||||
// a level set in QwenPaw is listed as it is
|
||||
o := static(qwenpawLevels...)
|
||||
if l := cur["effort"]; l == "off" || l == "budget" {
|
||||
o = append(o, Option{Value: l})
|
||||
}
|
||||
return o
|
||||
},
|
||||
}},
|
||||
}, path, prov)
|
||||
}
|
||||
@@ -543,7 +587,7 @@ var qwenpawOwned = []string{"id", "name", "base_url", "api_key", "chat_model", "
|
||||
// qwenpawModelOwned are the keys of one of magpie's models that are
|
||||
// magpie's to say, unless the user changed one in QwenPaw (the model's
|
||||
// config_overrides names it).
|
||||
var qwenpawModelOwned = []string{"id", "name", "source", "supports_image", "supports_multimodal", "supports_tool_calling", "max_input_length", "max_input_length_configured", "max_output_length"}
|
||||
var qwenpawModelOwned = []string{"id", "name", "source", "supports_image", "supports_multimodal", "supports_tool_calling", "max_input_length", "max_input_length_configured", "max_output_length", "thinking_param_style", "reasoning_effort_options"}
|
||||
|
||||
// qwenpawProviderJSON is magpie's provider file as it should be, from raw,
|
||||
// the file as it is (nil: none yet): OpenAI Chat at gw with key (the one
|
||||
@@ -601,6 +645,13 @@ func qwenpawProviderJSON(raw []byte, gw, key string, keep bool, models []catalog
|
||||
}
|
||||
}
|
||||
}
|
||||
// a null of magpie's takes back what it said before, and is
|
||||
// written nowhere it said nothing
|
||||
for k, v := range e {
|
||||
if _, had := was[m.ID][k]; v == nil && !had {
|
||||
delete(e, k)
|
||||
}
|
||||
}
|
||||
extra = append(extra, e)
|
||||
}
|
||||
out["extra_models"] = extra
|
||||
@@ -638,8 +689,36 @@ func qwenpawModelJSON(m catalog.Model) map[string]any {
|
||||
if n := maxTokens(m); n > 0 {
|
||||
e["max_output_length"] = n
|
||||
}
|
||||
// QwenPaw applies an agent's thinking level (agent.json thinking_level)
|
||||
// only to a model whose card declares how it thinks: with neither
|
||||
// thinking_param_style nor thinking_control, resolve_thinking drops
|
||||
// the level (providers/provider.py thinking_control, Pkh on Discord).
|
||||
// "effort" makes it send the level as Chat's reasoning_effort, held to
|
||||
// the levels the model has; none is left out, as QwenPaw turns an off
|
||||
// into Qwen's and DeepSeek's switches (extra_body enable_thinking,
|
||||
// thinking), not the reasoning_effort magpie hands every vendor.
|
||||
e["thinking_param_style"], e["reasoning_effort_options"] = nil, nil
|
||||
if levels := qwenpawEfforts(m.Efforts); len(levels) > 0 {
|
||||
e["thinking_param_style"], e["reasoning_effort_options"] = "effort", levels
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// qwenpawLevels are the thinking levels QwenPaw names (thinking.py's
|
||||
// ThinkingControl.efforts), weakest first.
|
||||
var qwenpawLevels = []string{"minimal", "low", "medium", "high", "xhigh", "max"}
|
||||
|
||||
// qwenpawEfforts are a model's reasoning levels that QwenPaw names, in
|
||||
// its order.
|
||||
func qwenpawEfforts(efforts []string) []string {
|
||||
var out []string
|
||||
for _, l := range qwenpawLevels {
|
||||
if slices.ContainsFunc(efforts, func(e string) bool { return catalog.EffortLevel(e) == l }) {
|
||||
out = append(out, l)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// what qwenpaw says after a change (notice.go)
|
||||
var noticeQwenpaw = newNotice("QwenPaw reads its providers at start-up — restart QwenPaw once after connecting it, and after magpie's models change; a model picked for an agent after that is used from its next message.")
|
||||
|
||||
@@ -140,7 +140,7 @@ func qwenpawHome(t *testing.T) (home, work string) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := catalog.SaveLive("kimi", "https://api.moonshot.cn/v1", []catalog.Model{
|
||||
{ID: "k2", Context: 262144, Output: 16384},
|
||||
{ID: "k2", Context: 262144, Output: 16384, Efforts: []string{"none", "low", "medium", "high", "max", "ultra"}},
|
||||
{ID: "k2-vision", Images: true},
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -533,3 +533,118 @@ func TestQwenPawNullModelRestored(t *testing.T) {
|
||||
t.Fatalf("Disconnect left\n%s", got)
|
||||
}
|
||||
}
|
||||
|
||||
// QwenPaw applies an agent's thinking level only to a model whose card
|
||||
// says how it thinks (Pkh on Discord: magpie's cards said nothing, so
|
||||
// thinking_param_style was null and resolve_thinking dropped the level).
|
||||
// A model of magpie's with reasoning levels is declared "effort" with the
|
||||
// levels QwenPaw names, none and ultra left out; one without says
|
||||
// nothing. A style the user set in QwenPaw stays, and one magpie said
|
||||
// before is taken back once the model has no levels.
|
||||
func TestQwenPawModelsDeclareThinking(t *testing.T) {
|
||||
_, work := qwenpawHome(t)
|
||||
prov := filepath.Join(work+".secret", "providers", "custom", "magpie.json")
|
||||
a := qwenpawFind(t, "qwenpaw")
|
||||
if err := a.Apply("model", "magpie/kimi/k2"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p := qwenpawJSON(t, prov)
|
||||
k2 := p.Get(`extra_models.#(id=="kimi/k2")`)
|
||||
if k2.Get("thinking_param_style").String() != "effort" {
|
||||
t.Fatalf("kimi/k2 declares no effort: %s", k2.Raw)
|
||||
}
|
||||
var levels []string
|
||||
for _, l := range k2.Get("reasoning_effort_options").Array() {
|
||||
levels = append(levels, l.String())
|
||||
}
|
||||
if !slices.Equal(levels, []string{"low", "medium", "high", "max"}) {
|
||||
t.Errorf("kimi/k2's levels: %v", levels)
|
||||
}
|
||||
vision := p.Get(`extra_models.#(id=="kimi/k2-vision")`)
|
||||
if vision.Get("thinking_param_style").Exists() || vision.Get("reasoning_effort_options").Exists() {
|
||||
t.Errorf("a model with no levels declares some: %s", vision.Raw)
|
||||
}
|
||||
|
||||
// the user's style for k2-vision, and magpie's for k2, whose levels go
|
||||
var m map[string]any
|
||||
json.Unmarshal([]byte(readFile(prov)), &m)
|
||||
for _, e := range m["extra_models"].([]any) {
|
||||
e := e.(map[string]any)
|
||||
if e["id"] == "kimi/k2-vision" {
|
||||
e["thinking_param_style"], e["reasoning_effort_options"] = "effort", []any{"high"}
|
||||
e["config_overrides"] = []any{"thinking_param_style", "reasoning_effort_options"}
|
||||
}
|
||||
}
|
||||
b, _ := json.MarshalIndent(m, "", " ")
|
||||
writeFile(t, prov, string(b))
|
||||
if err := catalog.SaveLive("kimi", "https://api.moonshot.cn/v1", []catalog.Model{
|
||||
{ID: "k2", Context: 262144, Output: 16384},
|
||||
{ID: "k2-vision", Images: true},
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
builtModels.Lock()
|
||||
builtModels.m = nil
|
||||
builtModels.Unlock()
|
||||
if err := a.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p = qwenpawJSON(t, prov)
|
||||
k2 = p.Get(`extra_models.#(id=="kimi/k2")`)
|
||||
if s := k2.Get("thinking_param_style"); s.Exists() && s.Type != gjson.Null {
|
||||
t.Errorf("kimi/k2 has no levels now and still declares them: %s", k2.Raw)
|
||||
}
|
||||
vision = p.Get(`extra_models.#(id=="kimi/k2-vision")`)
|
||||
if vision.Get("thinking_param_style").String() != "effort" || vision.Get("reasoning_effort_options.0").String() != "high" {
|
||||
t.Errorf("the user's thinking settings of kimi/k2-vision lost: %s", vision.Raw)
|
||||
}
|
||||
}
|
||||
|
||||
// The effort field is the agent's thinking_level in agent.json: a level
|
||||
// is written with no thinking_budget (QwenPaw refuses one beside any
|
||||
// level but budget), "" is QwenPaw's inherit, and a level QwenPaw
|
||||
// doesn't name is refused. A sync leaves the level alone.
|
||||
func TestQwenPawEffortField(t *testing.T) {
|
||||
_, work := qwenpawHome(t)
|
||||
path := filepath.Join(work, "workspaces", "default", "agent.json")
|
||||
var m map[string]any
|
||||
json.Unmarshal([]byte(readFile(path)), &m)
|
||||
m["thinking_level"], m["thinking_budget"] = "budget", 4096
|
||||
b, _ := json.MarshalIndent(m, "", " ")
|
||||
writeFile(t, path, string(b))
|
||||
a := qwenpawFind(t, "qwenpaw")
|
||||
if got := a.Field("effort").Get(); got != "budget" {
|
||||
t.Fatalf("effort read %q", got)
|
||||
}
|
||||
if err := a.Apply("model", "magpie/kimi/k2"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.Apply("effort", "high"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
j := qwenpawJSON(t, path)
|
||||
if j.Get("thinking_level").String() != "high" || j.Get("thinking_budget").Exists() {
|
||||
t.Fatalf("agent.json after effort high: %s", j.Raw)
|
||||
}
|
||||
if j.Get("active_model.provider_id").String() != "magpie" || j.Get("fallback_models.0.model").String() != "deepseek-reasoner" {
|
||||
t.Errorf("other keys changed: %s", j.Raw)
|
||||
}
|
||||
if err := a.Sync(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := qwenpawJSON(t, path).Get("thinking_level").String(); got != "high" {
|
||||
t.Errorf("a sync changed the level to %q", got)
|
||||
}
|
||||
if err := a.Apply("effort", "ultra"); err == nil {
|
||||
t.Error("a level QwenPaw doesn't name was taken")
|
||||
}
|
||||
if err := a.Apply("effort", ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := qwenpawJSON(t, path).Get("thinking_level").String(); got != "inherit" {
|
||||
t.Errorf("effort \"\" wrote %q", got)
|
||||
}
|
||||
if got := a.Field("effort").Get(); got != "" {
|
||||
t.Errorf("inherit reads as %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user