Yuu_jiang_ on X (#6849): 100milionseek and Coarena take at most 8 images a request, counted over the whole conversation, tool results included, and every turn after the ninth screenshot failed with no way on but /clear. ID-VerNe's max-images (the commit before) set one number from the CLI. This builds on it: - The cap is per provider, and optionally per model: max-images=8, or max-images=8,gemini-3-flash=10. The exact model is looked up first, then its upstream name, then "*" for all. The provider's cap moves with a model's local id like the other per-model limits. - 100milionseek's "At most 8 images per request (MAX_IMAGES)." and Coarena's "A request may carry at most 8 images." are learned as Copilot's words are, by provider and model, so the first refusal is the last. A user's own number is fitted before any refusal; a learned one that is smaller still lowers it. - Images are counted everywhere, a tool_result's too; the oldest are left out first and the latest user turn keeps its own. Only the request sent changes; session files are not touched. A request with no cap, or within it, goes out byte for byte as it came. - The provider editor's Advanced (folded unless set) has Images per request under Max output, in maximages.js, imported as that field is drawn, in every language. A GUI save keeps the value when the field isn't drawn. An editor opened and closed is not dirty (the draft takes the value only when typed), and the import, like keyrates.js's, draws nothing once the editor has closed: before that, a quick close threw "Cannot read properties of null (reading 'maxImages')" and ('keyPriceRates'), which add-sheet and key-box-once caught. - Budgets: app.js and the core +354, said in core_budget_test.go. What was run: - go test -count=1 -timeout 45m ./... on mote at618bfc1a9+ these two commits: 102 packages ok; internal/tui red on TestEveryWordHasZh ("subagent pool", red on main, fixed by6fbc24a05). After rebasing on origin/mainc9e8422fa: internal/gui (budgets), tui, agent, testenv, gateway and provider: all ok. gofmt clean; GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./... ok on mica. - At618bfc1a9+ these commits, on mote: provider-max-images 60/0, add-sheet 6/0, add-button 6/0, key-box-once 20/0, nokey-editor 4/0, provider-base-api 4/0, add-sheet-custom 32/0, kimi-subagent-pool 20/0, sync-signins-except 20/0; old-webkit 4/2 (#6030 headerpresets, #5919), i18n-keys 3/1 (#6877), provider-max-output 4/20 (#6209), editor-hints 30/10 (the same at origin/main, in #6934). - The whole GUI suite (1569 files, chromium + webkit, every language) on mote at the pre-fix head under another session's suite: 153 files red. Each red file rerun at the fixed head and at origin/mainad585ccd6on mica (and mote for the close ones). Red at head only: add-button (Escape showed the discard confirm: the dirty draft, fixed), add-sheet and key-box-once (the null draft above, fixed); now 3/0, 6/0, 20/0, provider-max-images 60/0. Every other red file is red the same at origin/main, the same subtests: filed with its numbers as #6934 (the #6782 class). i18n-keys' ", with an image" is #6877, old-webkit #6030/#5919, provider-max-output #6209. Broken by hand (each red, then put back): the relay words left out (TestImageCapLearnedFromRelayWords), per-model lookup by upstream name gone (TestMaxImagesOnAModelListedByItsOwnID), a copy made when nothing applies (TestImageCapNoneIsTheSameBytes), the learned cap over the user's (TestMaxImagesStandsOverTheLearnedCap), the GUI save dropping it (TestProviderSaveKeepsMaxImages), the CLI's empty value (TestProviderSetMaxImages), the cap not moving with a local id, the JS parse without its 1000 limit and the field not unfolding Advanced (provider-max-images), and the draft written on open (provider-max- images' Escape check, 20 red). Not tried: no real 100milionseek or Coarena account (the words are the reporter's literal ones); no GUI run on Windows or Linux; the suite's GUI half ran under load, so many reds are shared timeouts. Co-authored-by: ID-VerNe <yuu_seeing@foxmail.com>
75 lines
2.8 KiB
Go
75 lines
2.8 KiB
Go
package cli
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// magpie provider set max-images=8 is the user's word on how many images
|
|
// one request to a provider may carry (#6849, ID-VerNe: 100milionseek's and
|
|
// Coarena's APIs take 8 and refuse the ninth with their own words, and
|
|
// Copilot's wording alone is learned), show says so, max-images=0 hands it
|
|
// back to what a Copilot refusal teaches, and a value out of range is
|
|
// refused and leaves the saved one alone.
|
|
func TestProviderSetMaxImages(t *testing.T) {
|
|
groupsHome(t)
|
|
if _, err := printed(t, func() error { return providerCmd([]string{"provider", "set", "a", "max-images=8"}) }); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if p := mustFind(t, "a"); p.MaxImages["*"] != 8 {
|
|
t.Fatalf("max-images=8: %v", p.MaxImages)
|
|
}
|
|
out, err := printed(t, func() error { return providerCmd([]string{"provider", "a"}) })
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !strings.Contains(out, "max-images") || !strings.Contains(out, "8") {
|
|
t.Fatalf("show doesn't say the cap:\n%s", out)
|
|
}
|
|
for _, v := range []string{"-1", "1001", "abc", ""} {
|
|
err := providerCmd([]string{"provider", "set", "a", "max-images=" + v})
|
|
if err == nil || !strings.Contains(err.Error(), "max-images:") {
|
|
t.Errorf("max-images=%q: %v", v, err)
|
|
}
|
|
if mustFind(t, "a").MaxImages["*"] != 8 {
|
|
t.Errorf("a refused max-images=%q changed it", v)
|
|
}
|
|
}
|
|
if _, err := printed(t, func() error { return providerCmd([]string{"provider", "set", "a", "max-images=0"}) }); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if p := mustFind(t, "a"); len(p.MaxImages) != 0 {
|
|
t.Fatalf("max-images=0 left %v", p.MaxImages)
|
|
}
|
|
}
|
|
|
|
// max-images.<model>=n caps that model alone, beside the one for all
|
|
// models, and its 0 clears it alone.
|
|
func TestProviderSetMaxImagesPerModel(t *testing.T) {
|
|
groupsHome(t)
|
|
for _, kv := range []string{"max-images=8", "max-images.gemini-3-flash=10"} {
|
|
if _, err := printed(t, func() error { return providerCmd([]string{"provider", "set", "a", kv}) }); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
if p := mustFind(t, "a"); p.MaxImages["*"] != 8 || p.MaxImages["gemini-3-flash"] != 10 || len(p.MaxImages) != 2 {
|
|
t.Fatalf("both set: %v", p.MaxImages)
|
|
}
|
|
if p := mustFind(t, "a"); p.ImageCapOf("gemini-3-flash") != 10 || p.ImageCapOf("other") != 8 {
|
|
t.Fatalf("ImageCapOf: %d %d", p.ImageCapOf("gemini-3-flash"), p.ImageCapOf("other"))
|
|
}
|
|
out, err := printed(t, func() error { return providerCmd([]string{"provider", "a"}) })
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !strings.Contains(out, "gemini-3-flash=10") {
|
|
t.Fatalf("show doesn't say the model's cap:\n%s", out)
|
|
}
|
|
if _, err := printed(t, func() error { return providerCmd([]string{"provider", "set", "a", "max-images.gemini-3-flash=0"}) }); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if p := mustFind(t, "a"); p.MaxImages["*"] != 8 || len(p.MaxImages) != 1 {
|
|
t.Fatalf("its 0 cleared more than it: %v", p.MaxImages)
|
|
}
|
|
}
|