Files
magpie/internal/codexcat/deepseek_test.go
T
yetone 8acb0d3a7d codexcat: a DeepSeek model's Codex entry says what DeepSeek's own Codex setup says
Rollkey8 on X found DeepSeek in Codex through magpie duller than
DeepSeek's DSH. A real Codex 0.165.0 -> magpie -> api.deepseek.com
recording lost nothing in translation; what differed was the catalog
entry magpie writes for the model. DeepSeek's own Codex setup
(cdn.deepseek.com/api-docs/codex-deepseek-setup-en.sh) writes a
models.json for deepseek-flash and deepseek-v4-pro, and a DeepSeek
model's entry now takes its non-prompt fields from it:

- shell_type "shell_command" (Codex 0.165 reads it as unified_exec, its
  only shell tool, per openai_models.rs's serde alias; a Codex before
  that had a one-shot shell_command tool, which is what DeepSeek picks)
- support_verbosity true, default_verbosity "low" (text.verbosity low
  is sent)
- default_reasoning_summary "none": reasoning.summary "auto" is no
  longer sent; DeepSeek streams its reasoning as text
- multi_agent_version "v2" where magpie had none
- supports_image_detail_original on a model whose entry takes images

A DeepSeek model is deepseek-v4*/-flash/-pro/-chat/-reasoner after any
provider or relay prefix (codexcat.deepSeek); a routing group or an
R1-distill isn't one. Every other vendor's entry is unchanged.
default_reasoning_summary is tagged keep:"unset", so a value the user
put by hand in another model's entry stays through Keep, as it did
before magpie wrote the key anywhere.

Not taken, and why:
- base_instructions / model_messages: magpie never rewrites a model's
  Codex prompt (owner's rule).
- auto_compact_token_limit null: magpie's 272K Long conversations
  default came from a DeepSeek-flash latency report (e950eb080, ~550K
  turns waited 70-90s for a first token); Full window, or the model's
  Compact at, gives the whole 1M, and a model_auto_compact_token_limit
  the user set still comes first.
- supports_search_tool false on v4-pro: kept true for #258.
- reasoning levels: the provider's, as for every model.
- comp_hash, max_context_window (same as the window), web_search
  (config.toml, not the catalog).
- v4-pro's images: DeepSeek's pricing page, its live /models and
  models.dev all say text only, and magpie's own entry (/v1/models)
  says text. Codex's catalog lists it with image only when Settings ›
  Vision describes images for text-only models (codexListed's
  described()), by design.

Also adds the agent-wiring.md row "Codex: DeepSeek models".

What was run, at this tree (as daf576653, the same tree before the
gofmt commit was split out under it):
- TestCodexCatalogDeepSeekAsDeepSeekSays and
  TestCodexCatalogKeepsUsersSummary: red on the old codexcat.go (both
  FAIL with it stashed), green on the new.
- go test ./internal/codexcat ./internal/provider -run 'Codex|DeepSeek'
  on mote: ok.
- gofmt -l: clean. On mote: go vet ./..., GOOS=linux go vet -tags
  nogui ./..., GOOS=windows go vet ./..., go build, GOOS=linux go
  build -tags nogui, GOOS=windows go build: all ok.
- Full suite on mote, go test -count=1 -timeout 45m ./..., alone on
  the box: 79 packages ok; internal/gui red only in its 10 real-window
  AppKit tests, each killed at its deadline, which is #4125 (mote's
  AppKit hang; recorded there).
- Real use: Codex 0.165.0 in a sandbox HOME against a magpie built
  from this tree with the owner's DeepSeek provider copied in (deleted
  after). The written catalog has shell_command for both models. A
  multi-step task on deepseek-v4-pro (write a module and unittest file,
  run the tests, fix, report) ran to the end, tests pass. Through a
  recording proxy the requests carry text.verbosity "low", reasoning
  {effort: high} with no summary, and the same tools as before
  (exec_command, write_stdin, apply_patch, ...).

Not tried: a Codex older than 0.165, where shell_command is a tool of
its own; deepseek-flash in a real run (only v4-pro); a blind side by
side against DSH on answer quality.
2026-10-30 18:44:23 +08:00

107 lines
5.0 KiB
Go

package codexcat
import (
"encoding/json"
"path/filepath"
"testing"
"github.com/yetone/magpie/internal/catalog"
)
// A DeepSeek model's entry says what DeepSeek's own Codex setup says of
// its models (cdn.deepseek.com/api-docs/codex-deepseek-setup-en.sh, its
// models.json; Rollkey8 on X): the shell_command tool, low verbosity, no
// reasoning summary asked for, Codex's agents in V2, an image at its
// original detail on the one that takes images. Its prompt stays magpie's
// (never rewritten), and every other vendor's entry, a routing group and
// a model distilled onto another's base are as they were.
func TestCodexCatalogDeepSeekAsDeepSeekSays(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("USERPROFILE", home)
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
var got struct {
Models []map[string]any `json:"models"`
}
if err := json.Unmarshal(Catalog([]catalog.Model{
{ID: "deepseek/deepseek-v4-pro", Name: "DeepSeek V4 Pro", Context: 1048576, Efforts: []string{"low", "high", "max"}},
{ID: "deepseek/deepseek-flash", Name: "DeepSeek V4.1 Flash", Context: 1048576, Images: true, Efforts: []string{"low", "high", "max"}},
{ID: "relay/deepseek-ai/DeepSeek-V4-Pro-0813", Name: "DeepSeek V4 Pro 0813", Context: 1000000},
{ID: "moonshot/kimi-k3", Name: "Kimi K3", Context: 262144, Images: true, Efforts: []string{"low", "high"}},
{ID: "zai/glm-5.2", Name: "GLM-5.2", Context: 200000},
{ID: "group/deepseek", Name: "deepseek"},
{ID: "x/deepseek-r1-distill-qwen-32b", Name: "R1 Distill Qwen"},
}), &got); err != nil || len(got.Models) != 7 {
t.Fatalf("%v %v", err, got)
}
by := map[string]map[string]any{}
for _, e := range got.Models {
by[e["slug"].(string)] = e
}
for _, slug := range []string{"deepseek/deepseek-v4-pro", "deepseek/deepseek-flash", "relay/deepseek-ai/DeepSeek-V4-Pro-0813"} {
e := by[slug]
if e["shell_type"] != "shell_command" || e["support_verbosity"] != true || e["default_verbosity"] != "low" ||
e["default_reasoning_summary"] != "none" || e["multi_agent_version"] != "v2" {
t.Errorf("%s: shell %v, verbosity %v/%v, summary %v, agents %v; want DeepSeek's shell_command, true/low, none, v2",
slug, e["shell_type"], e["support_verbosity"], e["default_verbosity"], e["default_reasoning_summary"], e["multi_agent_version"])
}
if e["base_instructions"] != Prompt {
t.Errorf("%s: base_instructions changed; magpie never rewrites a model's Codex prompt", slug)
}
if e["truncation_policy"].(map[string]any)["limit"] != float64(10000) || e["apply_patch_tool_type"] != "freeform" {
t.Errorf("%s: truncation %v, apply_patch %v", slug, e["truncation_policy"], e["apply_patch_tool_type"])
}
}
if by["deepseek/deepseek-flash"]["supports_image_detail_original"] != true {
t.Error("deepseek-flash takes images: supports_image_detail_original true, as DeepSeek's setup says")
}
if v, ok := by["deepseek/deepseek-v4-pro"]["supports_image_detail_original"]; ok {
t.Errorf("deepseek-v4-pro takes no images; supports_image_detail_original %v", v)
}
if in := by["deepseek/deepseek-v4-pro"]["input_modalities"].([]any); len(in) != 1 || in[0] != "text" {
t.Errorf("deepseek-v4-pro input_modalities %v; DeepSeek lists it text only", in)
}
for _, slug := range []string{"moonshot/kimi-k3", "zai/glm-5.2", "group/deepseek", "x/deepseek-r1-distill-qwen-32b"} {
e := by[slug]
if e["shell_type"] != "unified_exec" || e["support_verbosity"] != false || e["default_verbosity"] != nil {
t.Errorf("%s: shell %v, verbosity %v/%v; another vendor's entry changed", slug, e["shell_type"], e["support_verbosity"], e["default_verbosity"])
}
for _, k := range []string{"default_reasoning_summary", "multi_agent_version", "supports_image_detail_original"} {
if v, ok := e[k]; ok {
t.Errorf("%s: %s %v; another vendor's entry changed", slug, k, v)
}
}
}
}
// default_reasoning_summary is written on DeepSeek's models alone, so a
// value the user put by hand in another model's entry stays, as it did
// before magpie wrote the key anywhere; on a DeepSeek model magpie's is
// the one Codex reads (config.toml's model_reasoning_summary still comes
// before both).
func TestCodexCatalogKeepsUsersSummary(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("USERPROFILE", home)
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
ms := []catalog.Model{
{ID: "deepseek/deepseek-v4-pro", Name: "DeepSeek V4 Pro"},
{ID: "zai/glm-5.2", Name: "GLM-5.2"},
}
cur := []byte(`{"models":[
{"slug":"deepseek/deepseek-v4-pro","default_reasoning_summary":"detailed"},
{"slug":"zai/glm-5.2","default_reasoning_summary":"concise"}]}`)
var got struct {
Models []map[string]any `json:"models"`
}
if err := json.Unmarshal(Keep(cur, Catalog(ms)), &got); err != nil {
t.Fatal(err)
}
want := map[string]string{"deepseek/deepseek-v4-pro": "none", "zai/glm-5.2": "concise"}
for _, e := range got.Models {
if s := e["slug"].(string); e["default_reasoning_summary"] != want[s] {
t.Errorf("%s: default_reasoning_summary %v; want %s", s, e["default_reasoning_summary"], want[s])
}
}
}