Files
magpie/internal/agent/opencode_inputs_test.go
T
yetone df4578438e models: a model listed bare takes what models.dev says, audio too
Parlevent_ on X: Gemini served through magpie from Vertex AI was listed
as taking text and images only, never audio. Vertex AI's models, and a
relay's, come from a list that says nothing of what a model takes, so
the entry had no input kinds and every agent's fallback said
text+image (provider.Entry.Modalities' Images branch).

catalog.InputsOf is now what most of models.dev's providers list a
model with, by bare id, as SeesImages, ContextOf and the others are
voted. provider.InputsOf uses it when the model's own source said
nothing of input (InputModalities and ImageInput both nil); a source's
own word, a plugin's included, still stands, and the image kind still
follows Images (the user's override included). The GUI's model row and
every agent's list read it through the Entry. OpenCode is now told
audio, video and pdf where the model takes them (its modalities enum
holds all five), not text+image only.

So Vertex AI's gemini-3.5-flash is text, image, audio, video, pdf;
gpt-oss-120b-maas there is text; a relay's bare gemini-3.5-flash is the
same as Vertex AI's. A model models.dev doesn't know stays unknown.

Also: a video sent to a bare-listed model models.dev lists without
video is now refused at magpie ("does not support video input") as it
is for a model whose own list says so, where it went upstream before.

Run (mica, mica-run):
- the new tests: TestGeminiTakesAudioWhereverServed (provider),
  TestInputsOf (catalog), TestOpenCodeInputs (agent): green; red on
  e9fcc6229 with the old code (vx/gemini-3.5-flash takes [text image],
  OpenCode told [text image])
- go test -count=1 -timeout 45m ./... at e9fcc6229 + this change:
  98 ok; red in . (TestNoEagerPackageRegexps, chatpage.go: #6689),
  internal/cli (/api/providers/delete, fixed in 4c86b0ab4) and
  internal/gateway (TestKeySlotEveryRoute and LazyCat manifest, the
  /deepseek-chat routes, fixed in cd030691a), none in code this touches
- again at 677034e1a + both commits: internal/cli, gateway, catalog,
  provider, agent, gui ok; . red only on #6689
- go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok; gofmt -l clean

Not tried: a real Vertex AI account; Codex, Pi, dsh and omp still take
text and image only, as their configs have no other kinds.
2026-11-15 01:25:49 +08:00

29 lines
1.0 KiB
Go

package agent
import (
"slices"
"testing"
"github.com/yetone/magpie/internal/catalog"
)
// OpenCode is told every kind a model takes that OpenCode knows, audio,
// video and pdf too, not text and image alone (Parlevent_ on X). A model
// that takes text alone is told nothing, as before.
func TestOpenCodeInputs(t *testing.T) {
for _, c := range []struct {
m catalog.Model
want []string
}{
{catalog.Model{ID: "g", Images: true, InputModalities: []string{"text", "image", "video", "audio", "pdf"}}, []string{"text", "image", "audio", "video", "pdf"}},
{catalog.Model{ID: "g-noimg", InputModalities: []string{"text", "image", "audio"}}, []string{"text", "audio"}},
{catalog.Model{ID: "v", Images: true}, []string{"text", "image"}},
{catalog.Model{ID: "t", InputModalities: []string{"text"}}, nil},
{catalog.Model{ID: "odd", InputModalities: []string{"text", "embedding"}}, nil},
} {
if got := openCodeInputs(c.m); !slices.Equal(got, c.want) {
t.Errorf("%s: %v, want %v", c.m.ID, got, c.want)
}
}
}