gateway: a turn that names no reply limit is sent the model's own as max_tokens on Anthropic's API, not a flat 16384 (#1792, tensornull)
Anthropic's Messages API needs max_tokens. A request that names none (Codex's Responses turns, a Chat client's) was always sent 16384, so a long thinking and tool turn on a Claude-shaped relay hit the limit, and Codex showed "Incomplete response returned, reason: max_output_tokens". Now such a request is sent askedOutput(p, model). That is the plain Served entry's PublishedOutput(), the same number the agents are told: the user's Max output first, else the vendor's list or models.dev, within the window. 16384 (defaultMaxTokens) is used only when nobody knows the limit. A limit the client names still goes as it is. The thinking budget is still fitted under max_tokens (anthropicBody), whatever the limit is. Both places that build an Anthropic body are covered: forwardTranslated, for every translated route, and serveZed for a Zed subscription's Claude models. The provider editor's Max output hint now says this number is also sent as max_tokens (en, zh, zh-TW, ja, de). docs/reference.md and docs/subsystems/gateway-routing.md no longer say the gateway never uses the limit. Run: - TestAnthropicMaxTokensIsTheModels covers: the user's 65536 (Responses plain and streamed, and Chat), models.dev's 64000, a 500000 limit held to the 100000 window, an unknown model at 16384, the client's own 1000, and thinking under 8192. - TestZedClaudeMaxTokensIsTheModels expects 40000 when the client names no limit and 1000 when it does. - Both tests fail on the old code: 16384 where the model's number was expected. - go test ./internal/gateway/ passed (1270s, under load). - provider-max-output.test.cjs passes 28/28 in chromium and webkit: 5 languages at 900 and 420px. The hint names max_tokens and Anthropic, is translated, and doesn't overflow. - gofmt -l is clean. go vet passes on darwin, on linux with -tags nogui, and on windows. Not tried against a real Anthropic-compatible relay with a real Codex session.
This commit is contained in:
+7
-2
@@ -1001,8 +1001,13 @@ numbers are kept, and are what its models take once it is serving again.
|
||||
A window is a number agents are shown **and a routing input**: at 95% of the
|
||||
window a request held on a routing-group member moves to one that takes more,
|
||||
so overstating a window makes that move happen too late. A reply limit is
|
||||
advertised in `/models` and is what a group advertises the smallest of; the
|
||||
gateway does not itself cap a reply by it.
|
||||
advertised in `/models` and is what a group advertises the smallest of. The
|
||||
gateway doesn't lower a limit an agent sends by it. A request that names none
|
||||
and goes to Anthropic's Messages API, which needs one (Codex's Responses turns,
|
||||
a Chat client's), is sent it as `max_tokens`, within the window as agents are
|
||||
told it. Only a model whose limit nobody knows goes at 16384. A reply that
|
||||
runs into it ends with `stop_reason: max_tokens`, which a Responses client
|
||||
reads as `incomplete_details.reason: "max_output_tokens"` (#1792).
|
||||
|
||||
Saving a window or a reply limit writes that number into the model lists magpie
|
||||
keeps in the agents' own files — Pi's `contextWindow` and `maxTokens`, OpenCode's
|
||||
|
||||
@@ -90,6 +90,7 @@ served by a plugin are in [Provider and plugin ownership](provider-plugins.md).
|
||||
- Claude Code's billing line (`x-anthropic-billing-header: cc_version=…; cc_entrypoint=…; cch=…;`, its own first system block, `cch` changing every turn) goes on only to a Claude model asked on Anthropic's Messages API (`keepsBillingLine` in [`billing_line.go`](../../internal/gateway/billing_line.go): Anthropic's, a relay's, Bedrock's), as Claude Code sent it. Anywhere else it is left out, the rest of the system as sent (`withoutBillingLine`): a vendor's model relayed on Messages (`passthrough`), every translation to Chat, Responses or Gemini (`forwardTranslated`, Claude models too), and the subscriptions asked through their own clients' APIs (Cursor, Devin, Kiro, Qoder, Zed, Command Code's Go plan, in `attempt`). Kept, a vendor read it as the prompt's first words and its prefix cache missed from byte 0 every turn (#1600, justrun1983: 4% read from DeepSeek's cache behind Command Code's plan). The Claude subscription's run sends its own (`withoutBillingHeader`), another magpie decides for the provider it picks, and Code Assist (Antigravity, Gemini CLI) is sent it as before, which `antigravityTurnsAway` reads (#666).
|
||||
- A model that refuses a conversation ending with the assistant's message (`refusesPrefill`: OpenCode Go's Claude models over Messages, "This model does not support assistant message prefill"; Volcengine's Agent Plan, "…for a model that does not support prefill"; Gemini's, "Requests ending with a model turn are not supported") is marked for that provider, model and API (`prefillRefused`, #1447); the provider's other models keep their prefill ([`prefill.go`](../../internal/gateway/prefill.go)). A Chat or Responses client's conversation ending with the assistant's message, which those APIs read as a turn already said (`Request.LastIsTurn`), is asked again with a user turn after it (`continueText`), translated (`forwardTranslated`) or relayed (`passthrough`, `userLastBody`), and so from then on. An Anthropic client's prefill is its own ask and gets the refusal as sent. magpie's own continuation of a cut reply (`continuation.go`) isn't asked of that model again; the try the model refused ends the reply with what cut it, not with the refusal. A request magpie builds in Gemini's own shape (`buildCodeAssistSent`: Vertex AI, Gemini CLI's and Antigravity's Code Assist, Factory) never ends with the model's turn, which all of them turn away: a user turn goes after it, `continueText`, or `compactLastText` when an agent is compacting with its ask in the system prompt (`modelLastAsk`), as one goes before a history that opens with the model's. Nor does it send a user turn that mixes a tool's `functionResponse` with text, which Vertex AI answers with the same "ending with a model turn" (#1533: Codex's compaction prompt after a tool's output): what the user said goes in a user turn of its own after the tools' responses (`hasResponse`), except for a Claude model on Antigravity, whose tool_result turn holds both.
|
||||
- A model's reply limit is published within the window beside it (#1438, `provider.OutputWithin`, `Entry.PublishedOutput`): `/v1/models`' `max_output_tokens` (`modelObject`), Cursor Private Inference's `capabilities.max_output_tokens` (`cursorLocalModel`), Muse Code's `limit.output` (`museModels`), the GUI's model and group rows (`providerInfo`, `providersState`), `magpie model output`, and every agent's file (`agent.maxTokens`, #338). The window and the output can come from different sources: Grok's backend lists grok-4.7's 256000 window, and models.dev fills its 500000 output (`catalog.Decorate` and `Provider.replyLimit` fill an output only where the vendor gives none). An unknown window or output is published as it is. The catalog keeps the unclamped `Entry.Output`, and a group's member is still asked for no more than that (`outputLimit`, `withMaxOutput`), so a request isn't lowered by the clamp. A limit the user set stays in their settings as they set it (`TestModelListsKeepOutputWithinTheWindow`).
|
||||
- A request that names no reply limit, translated to Anthropic's Messages API, which needs `max_tokens` (`forwardTranslated`; a Zed subscription's Claude in `serveZed`), is sent the model's published limit (`askedOutput` in [`maxoutput.go`](../../internal/gateway/maxoutput.go)): the user's Max output, else the vendor's list or models.dev, within the window. `anthropicBody`'s `defaultMaxTokens` (16384) is left only for a model whose limit isn't known. Every Codex turn on a Claude went at 16384 before, and a long thinking and tool turn ran out of it: `stop_reason: max_tokens` reaches a Responses client as `incomplete_details.reason: "max_output_tokens"` (#1792, tensornull). A limit the client names goes as it is. The thinking budget fits under the filled limit as under one the client named (`TestAnthropicMaxTokensIsTheModels`).
|
||||
|
||||
## Remote magpie APIs
|
||||
|
||||
|
||||
@@ -824,7 +824,7 @@ func anthropicBody(r *Request, model string, replay bool) []byte {
|
||||
}
|
||||
maxTokens := r.MaxTokens
|
||||
if maxTokens <= 0 {
|
||||
maxTokens = 16384
|
||||
maxTokens = defaultMaxTokens // the model's own is filled in before (askedOutput)
|
||||
}
|
||||
// a client that turned reasoning off — Codex's or a Chat client's
|
||||
// effort none, which Effort reads as low — is sent thinking off, not a
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/yetone/magpie/internal/catalog"
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
)
|
||||
|
||||
// A request that names no reply limit (Codex's Responses turns) is sent on
|
||||
// Anthropic's API with the model's own: the user's Max output, else the
|
||||
// vendor's list or models.dev, within the window, as the agents are told it.
|
||||
// It was sent a flat 16384, which a long thinking and tool turn ran out of
|
||||
// (#1792, tensornull: "Incomplete response returned, reason:
|
||||
// max_output_tokens"). 16384 stays for a model whose limit isn't known, and
|
||||
// a limit the client names goes as it is.
|
||||
func TestAnthropicMaxTokensIsTheModels(t *testing.T) {
|
||||
fresh(t)
|
||||
var mu sync.Mutex
|
||||
var asked map[string]any
|
||||
up := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
var q map[string]any
|
||||
b, _ := io.ReadAll(r.Body)
|
||||
json.Unmarshal(b, &q)
|
||||
mu.Lock()
|
||||
asked = q
|
||||
mu.Unlock()
|
||||
if q["stream"] == true {
|
||||
w.Header().Set("Content-Type", "text/event-stream")
|
||||
io.WriteString(w, "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"m\",\"type\":\"message\",\"role\":\"assistant\",\"content\":[],\"usage\":{\"input_tokens\":1,\"output_tokens\":0}}}\n\n"+
|
||||
"event: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\n"+
|
||||
"event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"ok\"}}\n\n"+
|
||||
"event: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\n"+
|
||||
"event: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\"},\"usage\":{\"output_tokens\":1}}\n\n"+
|
||||
"event: message_stop\ndata: {\"type\":\"message_stop\"}\n\n")
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
io.WriteString(w, `{"id":"m","type":"message","role":"assistant","content":[{"type":"text","text":"ok"}],"stop_reason":"end_turn","usage":{"input_tokens":1,"output_tokens":1}}`)
|
||||
}))
|
||||
t.Cleanup(up.Close)
|
||||
// models.dev's entry for a Claude model, and one listing a reply
|
||||
// limit past its window
|
||||
const known, wide = "claude-sonnet-4-5", "wide-1"
|
||||
os.MkdirAll(filepath.Dir(catalog.CachePath()), 0o755)
|
||||
if err := os.WriteFile(catalog.CachePath(), []byte(`{"anthropic":{"id":"anthropic","models":{
|
||||
"claude-sonnet-4-5":{"id":"claude-sonnet-4-5","limit":{"context":200000,"output":64000}},
|
||||
"wide-1":{"id":"wide-1","limit":{"context":100000,"output":500000}}}}}`), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
catalog.Reset()
|
||||
t.Cleanup(catalog.Reset)
|
||||
if err := provider.Save(provider.Provider{ID: "a", Name: "A", Key: "k", Models: []string{"set", known, wide, "mystery-9"}, Anthropic: up.URL + "/v1"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := provider.SetModelOutput("a/set", 65536); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s := New()
|
||||
maxTokens := func(path, body string) (int, map[string]any) {
|
||||
t.Helper()
|
||||
mu.Lock()
|
||||
asked = nil
|
||||
mu.Unlock()
|
||||
if code, raw := postJSON(t, s, path, body); code != 200 {
|
||||
t.Fatalf("%s %s: %d %s", path, body, code, raw)
|
||||
}
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
n, _ := asked["max_tokens"].(float64)
|
||||
return int(n), asked
|
||||
}
|
||||
for _, c := range []struct {
|
||||
name, path, body string
|
||||
want int
|
||||
}{
|
||||
{"the user's Max output, Codex's turn", "/v1/responses", `{"model":"a/set","input":"hi"}`, 65536},
|
||||
{"the user's Max output, streamed", "/v1/responses", `{"model":"a/set","input":"hi","stream":true}`, 65536},
|
||||
{"the user's Max output, a Chat client", "/v1/chat/completions", `{"model":"a/set","messages":[{"role":"user","content":"hi"}]}`, 65536},
|
||||
{"models.dev's", "/v1/responses", `{"model":"a/` + known + `","input":"hi"}`, 64000},
|
||||
{"models.dev's, within the window", "/v1/responses", `{"model":"a/` + wide + `","input":"hi"}`, 100000},
|
||||
{"none known", "/v1/responses", `{"model":"a/mystery-9","input":"hi"}`, defaultMaxTokens},
|
||||
{"the client's own", "/v1/responses", `{"model":"a/set","input":"hi","max_output_tokens":1000}`, 1000},
|
||||
} {
|
||||
if got, _ := maxTokens(c.path, c.body); got != c.want {
|
||||
t.Errorf("%s: max_tokens %d, want %d", c.name, got, c.want)
|
||||
}
|
||||
}
|
||||
|
||||
// thinking fits under the model's limit, as under a limit the client
|
||||
// named: a budget at or past max_tokens is refused with a 400
|
||||
if err := provider.SetModelOutput("a/set", 8192); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, q := maxTokens("/v1/responses", `{"model":"a/set","input":"hi","reasoning":{"effort":"high"}}`)
|
||||
th, _ := q["thinking"].(map[string]any)
|
||||
budget, _ := th["budget_tokens"].(float64)
|
||||
if got != 8192 || th["type"] != "enabled" || budget <= 0 || int(budget) >= got {
|
||||
t.Fatalf("max_tokens %d, thinking %v", got, q["thinking"])
|
||||
}
|
||||
}
|
||||
|
||||
// A Zed subscription's Claude is asked in Anthropic's request inside Zed's
|
||||
// envelope, so a turn naming no limit takes the model's own there too.
|
||||
func TestZedClaudeMaxTokensIsTheModels(t *testing.T) {
|
||||
fresh(t)
|
||||
var got []int64
|
||||
zedUpstream(t, "anthropic", func(w http.ResponseWriter, b []byte, _ string) {
|
||||
got = append(got, gjson.GetBytes(b, "provider_request.max_tokens").Int())
|
||||
zedLines(w,
|
||||
zedEvent(`{"type":"message_start","message":{"id":"m","role":"assistant","usage":{"input_tokens":1,"output_tokens":0}}}`),
|
||||
zedEvent(`{"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}`),
|
||||
zedEvent(`{"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"ok"}}`),
|
||||
zedEvent(`{"type":"content_block_stop","index":0}`),
|
||||
zedEvent(`{"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":1}}`),
|
||||
zedEvent(`{"type":"message_stop"}`),
|
||||
zedEnded)
|
||||
})
|
||||
// a provider of the user's stands in for the subscription in the
|
||||
// catalog ("zed" itself is the built-in's id), saved after zedUpstream
|
||||
// moves the config folder
|
||||
if err := provider.Save(provider.Provider{ID: "zz", Name: "Zz", Key: "k", Models: []string{"claude-sonnet-4-5"}, Anthropic: "http://zed.invalid/v1"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := provider.SetModelOutput("zz/claude-sonnet-4-5", 40000); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s := New()
|
||||
for _, body := range []string{
|
||||
`{"model":"zz/claude-sonnet-4-5","input":"hi"}`,
|
||||
`{"model":"zz/claude-sonnet-4-5","input":"hi","max_output_tokens":1000}`,
|
||||
} {
|
||||
w := httptest.NewRecorder()
|
||||
var u Usage
|
||||
p := provider.Provider{ID: "zz", Account: &provider.Account{Agent: "zed", User: "octo"}}
|
||||
if status, msg := s.serveZed(w, httptest.NewRequest("POST", "/", strings.NewReader(body)), provider.Responses, p, "claude-sonnet-4-5", []byte(body), &u); status != 200 {
|
||||
t.Fatalf("%s: %d %q\n%s", body, status, msg, w.Body.String())
|
||||
}
|
||||
}
|
||||
if len(got) != 2 || got[0] != 40000 || got[1] != 1000 {
|
||||
t.Fatalf("max_tokens %v, want [40000 1000]", got)
|
||||
}
|
||||
}
|
||||
@@ -4126,6 +4126,14 @@ func (s *Server) forwardTranslated(ctx context.Context, p provider.Provider, to
|
||||
r := *req
|
||||
r.Tier, req = "priority", &r
|
||||
}
|
||||
// Anthropic's API needs a reply limit: one the client didn't name
|
||||
// is the model's own, not a flat 16384 (#1792, askedOutput)
|
||||
if to == provider.Anthropic && req.MaxTokens <= 0 {
|
||||
if n := askedOutput(p, model); n > 0 {
|
||||
r := *req
|
||||
r.MaxTokens, req = n, &r
|
||||
}
|
||||
}
|
||||
wire := provider.UpstreamNameIn(wires, p.ID, model)
|
||||
sent := req
|
||||
if dropsBillingLine(p, to, model, wire) && billingHeader.MatchString(req.System) {
|
||||
|
||||
@@ -18,6 +18,26 @@ func outputLimit(p provider.Provider, model string) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// askedOutput is the reply limit a request that names none is sent on
|
||||
// Anthropic's Messages API, which needs one: the model's own as the agents
|
||||
// are told it (the user's Max output, else the vendor's list or
|
||||
// models.dev, within the window), or 0 when none is known. A Codex turn
|
||||
// names none, and was sent a flat 16384, which a long thinking and tool
|
||||
// turn ran out of, Codex showing "Incomplete response returned, reason:
|
||||
// max_output_tokens" (#1792, tensornull).
|
||||
func askedOutput(p provider.Provider, model string) int {
|
||||
for _, e := range provider.Served() {
|
||||
if e.Group == "" && e.Provider.ID == p.ID && (e.Model == model || e.ID == model) {
|
||||
return e.PublishedOutput()
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// defaultMaxTokens is what a request naming no reply limit is sent on
|
||||
// Anthropic's API for a model whose limit isn't known.
|
||||
const defaultMaxTokens = 16384
|
||||
|
||||
// withMaxOutput is body, in proto's words, asking for a reply of at most
|
||||
// limit tokens: a request that asks for more is lowered to limit, and
|
||||
// Anthropic's thinking budget, which must be under it, with it. A request
|
||||
|
||||
@@ -48,6 +48,12 @@ func (s *Server) serveZed(w http.ResponseWriter, r *http.Request, from provider.
|
||||
// the vendor's own API is told the answer's format in words
|
||||
req = req.inSystem()
|
||||
req.Model = model
|
||||
// a Claude model's request is Anthropic's, which needs a reply limit:
|
||||
// one the client didn't name is the model's own, as the Zed editor
|
||||
// sends it (#1792, askedOutput)
|
||||
if req.MaxTokens <= 0 && zed.Wire(zedProviderOf(p.Account.User, model)) == "anthropic" {
|
||||
req.MaxTokens = askedOutput(p, model)
|
||||
}
|
||||
ask := s.askZed(p.Account.User, model)
|
||||
if req.WebSearch && !searching(r.Context()) {
|
||||
if canSearch() {
|
||||
|
||||
@@ -9584,7 +9584,7 @@ function outputField() {
|
||||
light();
|
||||
const wrap = el("div", "cxfield");
|
||||
wrap.append(ox, row);
|
||||
return field(t("Max output"), wrap, t("The most a reply may hold, told to the agents as their max tokens; empty leaves it to the vendor and models.dev"));
|
||||
return field(t("Max output"), wrap, t("The most a reply may hold, told to the agents as their max tokens and sent as max_tokens on Anthropic's API when the agent names none; empty leaves it to the vendor and models.dev"));
|
||||
}
|
||||
|
||||
// compactField is the editor's Compact at (#876): where Codex and Claude
|
||||
|
||||
@@ -1243,7 +1243,7 @@ const I18N = {
|
||||
"Context window: {v} is not a length like 128k or 1m": "上下文窗口:{v} 不是 128k、1m 这样的长度",
|
||||
"Max output": "最大输出",
|
||||
"e.g. 32k · or gpt-6=128k, comma separated": "如 32k · 或 gpt-6=128k,逗号分隔",
|
||||
"The most a reply may hold, told to the agents as their max tokens; empty leaves it to the vendor and models.dev": "单次回复的最大 token 数,作为 max tokens 告知 Agent;留空则按厂商和 models.dev",
|
||||
"The most a reply may hold, told to the agents as their max tokens and sent as max_tokens on Anthropic's API when the agent names none; empty leaves it to the vendor and models.dev": "单次回复的最大 token 数,作为 max tokens 告知 Agent,Agent 没给时也作为 max_tokens 发给 Anthropic 的 API;留空则按厂商和 models.dev",
|
||||
"Max output: {v} is not a number of tokens like 32k": "最大输出:{v} 不是 32k 这样的 token 数",
|
||||
"Compact at": "压缩阈值",
|
||||
"e.g. 500k · or deepseek-v4-flash=272k, comma separated": "如 500k · 或 deepseek-v4-flash=272k,逗号分隔",
|
||||
@@ -5628,7 +5628,7 @@ const I18N = {
|
||||
"Context window: {v} is not a length like 128k or 1m": "上下文視窗:{v} 不是 128k、1m 這樣的長度",
|
||||
"Max output": "最大輸出",
|
||||
"e.g. 32k · or gpt-6=128k, comma separated": "如 32k · 或 gpt-6=128k,逗號分隔",
|
||||
"The most a reply may hold, told to the agents as their max tokens; empty leaves it to the vendor and models.dev": "單次回覆的最大 token 數,作為 max tokens 告知 Agent;留空則按廠商和 models.dev",
|
||||
"The most a reply may hold, told to the agents as their max tokens and sent as max_tokens on Anthropic's API when the agent names none; empty leaves it to the vendor and models.dev": "單次回覆的最大 token 數,作為 max tokens 告知 Agent,Agent 沒給時也作為 max_tokens 發給 Anthropic 的 API;留空則按廠商和 models.dev",
|
||||
"Max output: {v} is not a number of tokens like 32k": "最大輸出:{v} 不是 32k 這樣的 token 數",
|
||||
"Compact at": "壓縮閾值",
|
||||
"e.g. 500k · or deepseek-v4-flash=272k, comma separated": "如 500k · 或 deepseek-v4-flash=272k,逗號分隔",
|
||||
@@ -9989,7 +9989,7 @@ const I18N = {
|
||||
"Context window: {v} is not a length like 128k or 1m": "コンテキストウィンドウ:{v} は 128k や 1m のような長さではありません",
|
||||
"Max output": "最大出力",
|
||||
"e.g. 32k · or gpt-6=128k, comma separated": "例:32k · または gpt-6=128k(カンマ区切り)",
|
||||
"The most a reply may hold, told to the agents as their max tokens; empty leaves it to the vendor and models.dev": "1 回の返答の最大トークン数で、max tokens としてエージェントに伝えられます。空欄の場合はベンダーと models.dev に従います",
|
||||
"The most a reply may hold, told to the agents as their max tokens and sent as max_tokens on Anthropic's API when the agent names none; empty leaves it to the vendor and models.dev": "1 回の返答の最大トークン数で、max tokens としてエージェントに伝えられ、エージェントが指定しない場合は Anthropic の API に max_tokens として送られます。空欄の場合はベンダーと models.dev に従います",
|
||||
"Max output: {v} is not a number of tokens like 32k": "最大出力:{v} は 32k のようなトークン数ではありません",
|
||||
"Compact at": "圧縮しきい値",
|
||||
"e.g. 500k · or deepseek-v4-flash=272k, comma separated": "例:500k · または deepseek-v4-flash=272k(カンマ区切り)",
|
||||
@@ -14369,7 +14369,7 @@ const I18N = {
|
||||
"Context window: {v} is not a length like 128k or 1m": "Kontextfenster: {v} ist keine Länge wie 128k oder 1m",
|
||||
"Max output": "Max. Ausgabe",
|
||||
"e.g. 32k · or gpt-6=128k, comma separated": "z. B. 32k · oder gpt-6=128k, durch Kommas getrennt",
|
||||
"The most a reply may hold, told to the agents as their max tokens; empty leaves it to the vendor and models.dev": "Höchstzahl an Token einer Antwort, den Agenten als max tokens mitgeteilt; leer überlässt es dem Anbieter und models.dev",
|
||||
"The most a reply may hold, told to the agents as their max tokens and sent as max_tokens on Anthropic's API when the agent names none; empty leaves it to the vendor and models.dev": "Höchstzahl an Token einer Antwort, den Agenten als max tokens mitgeteilt und an Anthropics API als max_tokens gesendet, wenn der Agent keine nennt; leer überlässt es dem Anbieter und models.dev",
|
||||
"Max output: {v} is not a number of tokens like 32k": "Max. Ausgabe: {v} ist keine Token-Zahl wie 32k",
|
||||
"Compact at": "Komprimieren ab",
|
||||
"e.g. 500k · or deepseek-v4-flash=272k, comma separated": "z. B. 500k · oder deepseek-v4-flash=272k, durch Kommas getrennt",
|
||||
|
||||
@@ -64,4 +64,35 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
|
||||
// the hint says the size is also what a turn naming none is sent on
|
||||
// Anthropic's API as max_tokens (#1792, tensornull: Codex's turns were
|
||||
// sent a flat 16384), in every language, and fits a narrow window
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
for (const width of [900, 420]) {
|
||||
test(`${engine} ${lang} ${width}px: the max output hint names max_tokens on Anthropic's API`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
const page = await (await browser.newContext({ viewport: { width, height: 720 }, reducedMotion: "reduce" })).newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang, []));
|
||||
await page.goto("http://magpie.test/?view=providers");
|
||||
await page.locator(".row.provider").click();
|
||||
const box = page.locator("input.outputs");
|
||||
await box.waitFor();
|
||||
const hint = await box.evaluate((b) => document.getElementById(b.getAttribute("aria-describedby").split(" ").pop()).textContent);
|
||||
assert.match(hint, /max_tokens/, hint);
|
||||
assert.match(hint, /Anthropic/, hint);
|
||||
if (lang !== "en") assert.doesNotMatch(hint, /sent as max_tokens/, "translated: " + hint);
|
||||
const over = await box.evaluate((b) => {
|
||||
const h = document.getElementById(b.getAttribute("aria-describedby").split(" ").pop());
|
||||
return h.scrollWidth - h.clientWidth + Math.max(0, document.documentElement.scrollWidth - document.documentElement.clientWidth);
|
||||
});
|
||||
assert.equal(over, 0, "the hint wraps inside the window");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user