agent: Ante lists every magpie model whose reply limit reaches its window, told one token under it (#1179, liangkaichun)

Ante 0.2.9 skips a catalog entry whose max_tokens is not less than its
context_limit:

  warning: skipped catalog entry providers.magpie.preferred_models.b/eq:
  max_tokens (128000) must be less than context_limit (128000)

maxTokens caps the reply limit at the window (OutputWithin), so a model
whose list gives the same number for both, or a larger output, was
written with max_tokens == context_limit and went missing from Ante; the
reporter saw magpie's provider vanish from /provider. anteMaxTokens now
writes context_limit-1 in that case. Only Ante is changed: the other
agents magpie writes both sizes for (goose writes the window alone) have
no report or known check that turns away a reply limit equal to the
window; they were not each tried with equal values.

Run: real Ante 0.2.9 (darwin-arm64, download.ante.run) in a sandbox
HOME/ANTE_HOME: `ante catalog` printed the warning above for 128000/128000
and loaded the entry at 127999/128000. TestAnteMaxTokensUnderTheWindow
fails without the change (equal and over: max_tokens 128000 not under
context_limit 128000) and passes with it; go test -run TestAnte
./internal/agent passes.
This commit is contained in:
yetone
2026-10-10 18:31:31 +08:00
parent 27e69702e1
commit 1825d1e600
2 changed files with 46 additions and 2 deletions
+21 -2
View File
@@ -347,8 +347,8 @@ func anteModelJSON(m catalog.Model) map[string]any {
if m.Context > 0 {
e["context_limit"] = m.Context
}
if m.Output > 0 {
e["max_tokens"] = maxTokens(m)
if n := anteMaxTokens(m); n > 0 {
e["max_tokens"] = n
}
// Ante's ladder is per provider and model family; a model magpie knows
// the levels of says which of them Ante may send. No default "effort" is
@@ -361,6 +361,25 @@ func anteModelJSON(m catalog.Model) map[string]any {
return e
}
// anteMaxTokens is m's reply limit as Ante's catalog takes it: under the
// window, never equal to it. Ante 0.2.9 skips an entry whose max_tokens is
// not less than its context_limit —
//
// warning: skipped catalog entry providers.magpie.preferred_models.b/eq:
// max_tokens (128000) must be less than context_limit (128000)
//
// and maxTokens hands out a reply limit capped at the window, so a model
// whose list gives the same number for both (or a larger output) went
// missing from Ante, and with it magpie's provider when that was the model
// picked (#1179). Such a model is told one token less than its window.
func anteMaxTokens(m catalog.Model) int {
n := maxTokens(m)
if m.Context > 0 && n >= m.Context {
n = m.Context - 1
}
return n
}
// anteLadder is Ante's effort scale, ascending, and the magpie level each
// of its rungs is. Ante's lowest rung, "min", is not a name magpie lists:
// Ante's reference says what it sends it as (docs.antigma.ai,
+25
View File
@@ -743,3 +743,28 @@ func TestAnteGroupSaysNoCapabilities(t *testing.T) {
t.Fatalf("no group in the list: %v", anteModelList(t, path))
}
}
// Ante skips a catalog entry whose max_tokens is not under its
// context_limit, so a model whose reply limit reaches its window is told
// one token less (#1179, liangkaichun).
func TestAnteMaxTokensUnderTheWindow(t *testing.T) {
for _, c := range []struct {
name string
context, output int
want any
}{
{"equal", 128000, 128000, 127999},
{"over", 128000, 384000, 127999},
{"under", 200000, 64000, 64000},
{"no window", 0, 64000, 64000},
{"no output", 128000, 0, nil},
} {
e := anteModelJSON(catalog.Model{ID: "p/m", Context: c.context, Output: c.output})
if got := e["max_tokens"]; got != c.want {
t.Errorf("%s: max_tokens %v, want %v (%v)", c.name, got, c.want, e)
}
if n, ok := e["max_tokens"].(int); ok && c.context > 0 && n >= c.context {
t.Errorf("%s: max_tokens %d not under context_limit %d", c.name, n, c.context)
}
}
}