Files
magpie/internal/provider/channel_images_test.go
T
yetone f51863b3da catalog: a relay channel's word before a known model is that model, so Codex lets it see images (#2157)
The reporter's relay lists nyro-gpt-5.5, nyro-gemini-3.8-flash and
nyro-deepseek-v4.1-flash. None of those ids is in models.dev, so magpie
knew nothing about them: magpie-models.json gave each one
input_modalities ["text"], no context window and no reasoning levels, and
Codex refused every image. The bare ids are known (gpt-5.5: images, a context
window and reasoning levels).

renamed now also takes a leading channel word off an unknown id: 2 to 24
lowercase letters and a dash, when what is left has a digit and is a
known model. models.dev's own data backs it: 147 of its listed ids have
the form word-<another listed id> (openai-, databricks-, anthropic-,
doubao-, zai-, ...), and each is the same model. A listed id is never
renamed, so a vendor's own chan-gpt-5.5 keeps its entry; nyro-auto,
ny2-gpt-5.5 and nyro-gpt-5.5x stay unknown. NameOf keeps the word, so the
shown name is still the relay's own.

TestRenameNeverTakesAModelForAnother (#1383) had
anthropic-deepseek-v4.1-flash as a near miss. By the evidence above, that
id is DeepSeek's model under a vendor word, so the guard row is now
anthropic2-deepseek-v4.1-flash, which the rule still leaves alone.

A model magpie still can't place stays text-only: telling Codex a
text-only model sees images makes it offer view_image and fails the turn
upstream. For those the per-model "sees images" switch already writes
image into the catalog, which TestChannelModelsReachCodexWithImages
covers along with the renamed ids.

Run: go test -tags nogui for internal/catalog, codexcat, provider,
gateway (40m timeout; load ~380 from other sessions) and agent; gofmt -l;
go vet darwin, GOOS=linux -tags nogui, GOOS=windows. With the channel rule
turned off by hand both new tests go red (nyro-gpt-5.5 images false,
window 0; input_modalities [text]).
Not tried: a real Codex image turn through the reporter's relay.
2026-10-14 19:06:50 +08:00

62 lines
2.4 KiB
Go

package provider
import (
"encoding/json"
"os"
"path/filepath"
"slices"
"testing"
"github.com/yetone/magpie/internal/catalog"
"github.com/yetone/magpie/internal/codexcat"
"github.com/yetone/magpie/internal/settings"
)
// #2157 (sstdgm): a custom provider's nyro-gpt-5.5 is GPT-5.5 on the
// relay's channel, and Codex's catalog says it takes images; its
// nyro-deepseek-v4.1-flash, text-only by models.dev, stays text-only, and
// the user's own word on a model it doesn't know still counts.
func TestChannelModelsReachCodexWithImages(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("USERPROFILE", home)
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
os.MkdirAll(filepath.Dir(catalog.CachePath()), 0o755)
if err := os.WriteFile(catalog.CachePath(), []byte(`{
"openai":{"models":{"gpt-5.5":{"id":"gpt-5.5","modalities":{"input":["text","image"],"output":["text"]},"limit":{"context":400000,"output":128000}}}},
"deepseek":{"models":{"deepseek-v4.1-flash":{"id":"deepseek-v4.1-flash","modalities":{"input":["text"],"output":["text"]},"limit":{"context":1000000,"output":65536}}}}}`), 0o644); err != nil {
t.Fatal(err)
}
catalog.Reset()
t.Cleanup(catalog.Reset)
p := Provider{ID: "litelln-nyro"}
// the user said the channel's own nyro-gpt-5.5-tj, which models.dev
// doesn't know, takes images
s := settings.Settings{ModelImages: map[string]bool{"litelln-nyro/nyro-gpt-5.5-tj": true}}
var ms []catalog.Model
for _, id := range []string{"nyro-gpt-5.5", "nyro-deepseek-v4.1-flash", "nyro-gpt-5.5-tj"} {
e := entryFor(p, catalog.Model{ID: id}, s)
ms = append(ms, catalog.Model{ID: e.ID, Name: e.Name, Images: e.Images})
}
var cat struct {
Models []struct {
Slug string `json:"slug"`
Modalities []string `json:"input_modalities"`
} `json:"models"`
}
if err := json.Unmarshal(codexcat.CatalogAt(ms, ""), &cat); err != nil {
t.Fatal(err)
}
want := map[string]bool{"litelln-nyro/nyro-gpt-5.5": true, "litelln-nyro/nyro-deepseek-v4.1-flash": false, "litelln-nyro/nyro-gpt-5.5-tj": true}
for _, m := range cat.Models {
if got := slices.Contains(m.Modalities, "image"); got != want[m.Slug] {
t.Errorf("%s: input_modalities %v, want image %v", m.Slug, m.Modalities, want[m.Slug])
}
}
if len(cat.Models) != 3 {
t.Fatalf("catalog has %d models", len(cat.Models))
}
}