diff --git a/docs/subsystems/gateway-routing.md b/docs/subsystems/gateway-routing.md index 639349268..f12da3e62 100644 --- a/docs/subsystems/gateway-routing.md +++ b/docs/subsystems/gateway-routing.md @@ -191,7 +191,7 @@ recorded as a prediction failure (`noPrediction`). - A streamed request is never left silent while its vendor says nothing. `holdWriter.watch` runs beside each try: past `keepHeldAfter` (3s) it sends a held try's agent the stream's 200 and SSE comments (`keepAlive`), one every `keepHeldEvery` (5s), none of the try, so another candidate may still answer in the same stream. It was 15s, and a proxy between the agent and magpie that hangs up on a request with nothing back for about 10s ended every turn slower to its first event: Codex on Windows sends 127.0.0.1 through a Clash-style app's system proxy, `127.*` in its bypass list or not, and its turns ended 499 (mrten_95615 on Discord; `TestHeldStreamHeardBeforeAProxyCuts`). A failure before it is still a status; once the reply passes, it puts a comment between two of its lines after `keepaliveEvery` of quiet. It stops after `keepaliveLongest` (5 minutes) with nothing from the vendor. A translated stream (`streamTranslated`) whose upstream has begun its reply and then says nothing at all, not even a comment (a relay that sends the rest of a long reply in one burst at its end), is kept alive in the client's own protocol by a ticker beside its reader (`keepThroughSilence`): every `keepaliveEvery` it sends the client's keepalive (`enc.keepalive`: a ping for Anthropic, `response.in_progress` for Responses, a comment for Chat, nothing for Gemini), which also counts as the try heard from, so the held stream's comments go on too; it stops once the upstream has been silent for `translatedQuietLongest` (30 minutes), past the 10 minutes `upstreamHeaderWait` gives a vendor to begin and long enough for a long reasoning turn sent whole at its end, after which the client's own timeout ends the wait (youyo.p on Discord: before, Claude Code heard only comments, which its event watchdog doesn't count, and gave up 300s on; `TestTranslatedSilenceKeptAliveForABound`). An upstream that has answered its headers but sent no byte yet is still waited for under the held stream's comments alone (`notAnAPIReply` reads its first bytes before the reply is translated). An Anthropic client is sent a ping at most once each `pingEvery` (1 minute), comments between, and none before `message_start`: Claude Code's watchdog counts only 30 pings in a row as life, and a ping on every upstream keepalive spent them in the first minute; the SDKs' `MessageStream` fails on any event before `message_start` (`anthropicEncoder.keepalive`, `TestTranslatedStreamKeepsClientAlive`). A try waiting for its key's or account's slot or for room in its minute (`lanes.take`, `rpms.wait`) is kept alive the same way (`keepQueued`), for as long as it waits; once the 200 is out, the try is held, and its failure or its queue turning it away reaches the agent as the stream's error (`failTo`), not a status (coeo91 on Discord). A wait shorter than `keepHeldAfter` sends nothing, so its 429 keeps its `Retry-After`. A proxy in front such as Cloudflare (125s) otherwise ends the request (#947). Gemini streams get no comments (#934). A vendor that then ignores `stream:true` and answers 200 with its reply whole has it sent as the agent's stream (`wholeAsStream`: Chat, Responses, Anthropic), not as the stream's error, while a reply under a type that says neither JSON nor a stream is held as a stream when its first bytes are one (`sseStart`), read event by event like one that says so, so an error among its frames still goes to the next candidate (#1418: it went through at once); a Chat stream a vendor ends with `finish_reason:"error"` — WorkBuddy's and a DeepSeek harness's word for a turn it failed, not finished (#2471) — is the failure the word says, held for the group's next candidate, and nobody rests, as an empty reply's (`TestFinishReasonErrorFailsOver`); a 200 that is no reply of the protocol's fails as a translated reply that didn't stream does (502, "… did not stream"), for the next candidate to answer, and the last one's reaches the agent as the stream's error. A held stream that has sent nothing but the frames before a reply (`response.created`, `response.in_progress`, `codex.rate_limits`, pings, an empty part begun, and any event `streamEvent` doesn't know to carry text, reasoning, a call or a reply's end (`replyEvent`), or an item not known that isn't a call or a tool's (`streamPart.said`): `eventLead`; Aliceonly on #1418: an unknown event was taken for content and let a frames-only 200 through, and its `server_is_overloaded` reached Codex with five candidates left) stays held as long as its agent is kept alive, up to `holdLead` (4 minutes, under the 300s Codex waits for an event; `keptQuiet`), so a `server_is_overloaded` that comes after it is a failure the next candidate answers (#1418: let through at 15s, the ChatGPT backend's failure 36s in ended Codex's turn with sub2api, next in the group, never asked). A stream whose agent can't be kept alive (Gemini's) is let through after `holdLongest` (15s), as before. Codex counts only events toward that 300s, not comments, so the bound is the request's, not each try's: once Codex on Responses has heard no event for `agentQuietMost` (4 minutes) since the request began or its last event (`keptAlive.tooQuiet`), the try in hand is let through (`scan`, `keepQuiet`), and no group replan or same-one retry is taken whose pause would end past it (fadenoob on Discord: held tries and replan pauses added up past 300s and Codex reconnected on "idle timeout waiting for SSE"). A translated reply whose upstream stream stops before it said its reply had — an Anthropic one with no stop_reason and no message_stop, a Responses one with no `response.completed`, the same two a relayed one is told by (`sniff.whole`; a Chat stream may end without `[DONE]` and be whole), a Gemini or Code Assist one whose last chunk has no candidate's `finishReason` (`geminiEnds`, #1643: `usageMetadata` is no end, Vertex AI sends it on every chunk; a chunk with no candidate at all is the empty reply's to answer, #667), and a relayed Gemini one told the same way (#1644; it ends in Gemini's own `{"error":{"code":502,…,"status":"UNAVAILABLE"}}` data line from `streamFailure`, `TestGeminiRelayEndedShort`; whatever a relayed stream gets appended, that error or a filled-in `finish_reason`, begins after a blank line, two newlines when the upstream's last write stopped inside a line, so it is an event of its own rather than more of the half-written one, #2446, `TestPassthroughStreamCutMidLine`, `TestGeminiCompatFinishAfterPartialLine`), and a Chat one from Gemini's OpenAI-compatible API (`geminiCompat`) with no `finish_reason`, relayed or translated (`saysItsEnd`; Linka on Discord: the upstream hung up between a whole function call and its `finish_reason`, and Pi threw the call away as "Stream ended without finish_reason"; that API counts the usage only once the generation is done, so when the last chunk carried it only the `finish_reason` was lost and it is filled in, `tool_calls` after a call and `stop` otherwise, as a relayed chunk before `[DONE]` or a translated reply's end, and the reply counts as whole (`chatTail`); only one with no usage at its end is a cut, `TestGeminiCompatRelayEndedShort`, `TestGeminiCompatTranslatedEndedShort`) — ends the turn with "the reply ended before it was complete" (`errEndedShort`, `TestResponsesUpstreamEndedShort`, `TestGeminiUpstreamEndedShort`), asked again in place where the upstream goes on from a prefill (`continuation.go`). A client that asked for no stream is told the same 502 of such a cut (`translate`, `TestNonStreamEndedShort`, `TestGeminiNonStreamEndedShort`), rather than handed what came as its whole reply. A translated reply from an Anthropic or Responses upstream that ended but said nothing (no text, call, search or image) and counted no token at all is no reply either, whatever its end says (`repliesCounted`, #2086: an Anthropic-compatible proxy's 200 ended a Codex turn as `response.completed` with no output, no usage and no served model, and Codex didn't ask again). It is the empty reply's to answer (#667): asked again in place, then failed with "an empty reply", streamed or not, for every client (`TestUncountedEmptyReplyFails`, `TestUncountedEmptyReplyFailsEveryClient`). Claude's own empty `end_turn` counts its prompt and stays a whole reply (`TestWellFormedStreamsStillComplete`). A reply passed through in its own protocol isn't read this way. - A vendor's error keeps its `code` and `param` on its way to an OpenAI-shaped client (`writeVendorError`), where `writeError` used to set both to null: a status error relayed or translated, and a request refused inside a Responses stream. A Responses stream's `error` event or failed response whose error is of type `invalid_request_error` is the request at fault (`requestRefused`, read by its type, not its words): its `Event` carries status 400 and the vendor's error (`Event.Said`), so a client answered whole gets the vendor's 400 with its code and param (the whole-translated path wrote 502 `api_error`), a reply cut by it isn't resumed (`continuation.again`), and a translated stream's error says the vendor's type, code and param (`saidError`), so `holdWriter` reads it as the 400 it is. Before, the hold read magpie's `api_error` as a 502: the same request was sent three times, then to the other accounts, and every one rested (magpie-releases#18: the ChatGPT backend answers `access_programs` naming a program the workspace hasn't got with a 200 stream whose error is `access_program_not_enabled`). Asked once, nobody rests ([`codex_access_programs_test.go`](../../internal/gateway/codex_access_programs_test.go)). - An error that reaches the agent in a stream already begun can't carry its status, so `streamError` says it in the words (`saysPassing`, #2372, zminds): for a status that may pass (408, 429, 5xx) whose text names none of the words a text-judging agent retries on (Pi decides by its `errorMessage` alone), it appends `(: you can retry your request)`; a request's own fault (400, 401, 404 …) and a text that already says so are left as they were. `TestStreamErrorSaysItPasses` holds Pi's own lists; `TestGroupLastFailureInStreamSaysItPasses` runs a group whose last member fails after the keepalive. A 413 byte cap in that stream says `request_too_large` in the error text, and Chat and Anthropic name that type, so Pi compacts; Gemini keeps its own status shape (`TestStreamedByteCapSaysRequestTooLargeToPi`, `TestStreamErrorByteCapInEveryShape`). Wherever the protocol says a model with the error (Chat's first chunk, Anthropic's `message_start`, Responses' `response.created` and the events after it), it is the model the agent asked for, as `serve` has it, an effort on it kept (`keptAlive.model`; on Codex's own sign-in, the one Codex wrote) (#3728, jilen: with `"model":""` fx took Chat's first chunk for a broken one and stopped there; `TestStreamErrorNamesTheModel`, `TestKeptAliveChatErrorNamesTheModel`, `TestKeptAliveChatOnCodexErrorNamesTheModel`, `TestKeptAliveCodexErrorNamesTheModel`). An error after a reply that already went, a loop cut's, still starts a message of its own after the vendor's, under a new id and no model (#3792). -- Claude's, GPT's and Gemini's reasoning is held (`refusesAfterThinking`, up to `holdThinking`, 4 minutes) so that a refusal after it goes to the next candidate unseen (#248). It is held only while one could: on the last candidate a refusal isn't asked again, so their reasoning streams as it comes there, and a refusal after it reaches the agent as the vendor's own. Held there, a lone relay's Claude or GPT showed Claude Code its thinking all at once with the text, and Codex none until then (iTianbao on X). Gemini's streams there too: a reply that only reasoned is asked again in place by `streamTranslated`, the reasoning the agent has kept and the next try's after it (#667), so holding it only kept Codex on a Gemini model with nothing at all, not even `response.created`, for the whole of its thinking (LuckymanJC on Discord; `TestThinkingStreamsWithNoOneElse`'s gemini cases). Any other model's reasoning is never held. +- Claude's, GPT's, Gemini's and DeepSeek's reasoning is held (`refusesAfterThinking`, up to `holdThinking`, 4 minutes) so that a refusal after it goes to the next candidate unseen (#248). It is held only while one could: on the last candidate a refusal isn't asked again, so their reasoning streams as it comes there, and a refusal after it reaches the agent as the vendor's own. Held there, a lone relay's Claude or GPT showed Claude Code its thinking all at once with the text, and Codex none until then (iTianbao on X). Gemini's streams there too: a reply that only reasoned is asked again in place by `streamTranslated`, the reasoning the agent has kept and the next try's after it (#667), so holding it only kept Codex on a Gemini model with nothing at all, not even `response.created`, for the whole of its thinking (LuckymanJC on Discord; `TestThinkingStreamsWithNoOneElse`'s gemini cases). DeepSeek's is held since plugins #540: deepseek-v4.1-flash on WorkBuddy reasoned, then ended `content_filter` with nothing said (the WorkBuddy plugin takes the filter's canned "Sorry, I can't respond to this question." out of such a reply), and with its reasoning already through, the group's next member was never asked (`TestDeepSeekRefusalAfterThinkingFailsOver`). Any other model's reasoning (GLM's, Kimi's…) is never held. - A streamed reply stuck in a loop is ended, not let run to its output limit (#1359, Moody-Sin: WorkBuddy's DeepSeek v4.1 flash reasoned round "Now." "Writing." "Go." "Let me write." "OK." until max tokens while dsh and Pi waited). `holdWriter.Write` feeds every streamed try, passed through or translated, a key's, a built-in subscription's or a plugin's (a moved WorkBuddy's fetch in the plugin host, `TestLoopEndsWorkBuddysReply`), in each of the agent's protocols, to a `loopGuard` ([`loop_guard.go`](../../internal/gateway/loop_guard.go)). It cuts the reasoning and the text, each apart, into units, its lines and sentences (a list's `1.` or a decimal is no sentence's end), compared without case or a closing stop. A unit with no word in it (a letter run with no digit: not a brace, a rule, `0x00`, a hash or a row of numbers) isn't counted. When the last `loopWindow` (256) counted units of either are among no more than `loopDistinct` (24) different ones, the try is cut (`cutLoop`): what came with that write goes out, then, after a blank line (two newlines when that write stopped inside a line, `holdWriter.atLine`, #2446), the protocol's stream error (`streamError`, 502) naming the loop and quoting its units, and the vendor's request is cancelled. It falls back to nobody and rests nobody (`failLoop`); its usage record's error type is `reply_loop` (`usage.LoopErrType`), and Usage counts them per model (`Totals.Loops`), as "{n} looped" beside the model's failures in the Overview's rows and the Requests ranking (#1858, `TestLoopsCountedPerModel`, `usage-loops.test.cjs`). A reply magpie translates into the agent's protocol (`streamTranslated`) whose *reasoning* loops before it has said a text or a call, and isn't a continuation, is asked again once in place instead (`loopReasks`, through `holdWriter.onLoop`; cdredfox on X, WorkBuddy AI's DeepSeek v4 flash): the agent keeps the reasoning it has, the next try's follows it in the same stream, as an empty reply's re-ask does (#667), and only a loop on that try ends the reply with the error (`TestReasoningLoopIsAskedAgain`). A reply passed through in the agent's own protocol is asked again once too, at the fallback loop (`holdWriter.mayReloop`, `letGoLoop`; #2436, lqisgod: pi's Chat stream to WorkBuddy was cut at once): when nothing of the try has reached the agent yet, in any protocol, its held bytes are dropped; when its reasoning is already passing, only a Chat stream goes on, written up to the end of the tripping event, with the next try's chunks after it. An Anthropic or Responses stream already passing still ends with the error, since a second `message_start` or `response.created` can't follow. Each re-ask, in place or at the fallback loop, counts in the usage record's tries. A loop in the text, or after a text or call, is ended at once (`TestLoopAfterTextIsNotAskedAgain`). A cycle need not be exact. Code, tables, lists, logs, CSV and base64 differ line to line or have no words, and don't trip it (`TestLoopGuardLeavesOrdinaryRepliesAlone` feeds magpie's own sources and docs through it). A reply sent whole (no stream, or Gemini without `alt=sse`) isn't read. Settings › Models › Replies › *Stop looping replies* (`noLoopGuard`) turns it off. - A conversation going round one tool call is answered by magpie and sent nowhere (audie on Discord: Codex Desktop on WorkBuddy's deepseek-v4-pro read the same file 308 times in half an hour, and 340 times that evening, 537 credits). `stoppedToolLoop` ([`tool_loop.go`](../../internal/gateway/tool_loop.go)) runs in `serveAgent` before hooks, middleware and routing, and in the Codex backend's passthrough on Codex's own sign-in. It reads the request's own history, so it is per conversation and keeps no state: when the last `toolLoopRepeats` (8) turns are each the same calls (name and arguments, keys in any order, call ids ignored) answered with the same results (with Codex's `Wall time`, `Chunk ID` and `duration_seconds` taken out, `runNoise`) and nothing else from the user, the turn is answered in the agent's own protocol, streamed or whole (`writeLocalText` through `relayStatus`), with a notice naming the call. Any different result, or a word of the user's, starts the count again; the notice is a turn without calls, so the user's next word goes on. A body with fewer than 8 tool results isn't parsed (`mayLoop`), and only the newest 64 items of a long one are (`tailOf`, gjson), ~1ms for a 1.5MB turn (`BenchmarkToolLoopCheck`). The turn is recorded as Codex's title turns are (`answeredHere`): the Routing trace as "Tool loop stopped", and a usage row with provider `magpie`, rejected, its session and an error starting `tool loop:`. A poll that gets the same answer 8 times in a row is stopped too. Settings › Models › Replies › *Stop looping replies* (`noLoopGuard`) turns it off with the reply guard. Verification: `go test -tags nogui ./internal/gateway -run 'TestToolLoop'`. - A Chat request's earlier turns carry the assistant's thinking back in the spelling its own client used: `reasoning_content` (DeepSeek's, which OpenCode and most clients send), `reasoning` (OpenRouter's) or `reasoning_details` (OpenRouter's structured one). A request translated to a non-Chat upstream reads whichever of the three the turn has, in that order, as the turn's thinking (`messageReasoning`, `reasoningText`, read by `parseChat` in [chat.go](../../internal/gateway/chat.go)); the passthrough has read all three since `mistralThinking` (#494), which was the one place that did. Before that the parse layer read `reasoning_content` alone, so a tool-calling session whose client spelled it another way went on from its second turn without the model's own reasoning. diff --git a/internal/gateway/fallback.go b/internal/gateway/fallback.go index 9543ca3e0..8b0ef767f 100644 --- a/internal/gateway/fallback.go +++ b/internal/gateway/fallback.go @@ -2266,10 +2266,15 @@ func (h *holdWriter) keptQuiet() bool { // refusesAfterThinking tells whether a model's vendor may end a reply that // has only reasoned with its safety filter's refusal: Claude's stop_reason -// refusal, OpenAI's content_filter or bio_policy, Gemini's SAFETY (#248). -// Anybody else's reasoning — GLM's, DeepSeek's, Kimi's… — is shown as it -// comes: held, GLM on a ZCode account through a group showed Claude Code -// its thinking only once the text began, all at once (悠悠哥 on Discord). +// refusal, OpenAI's content_filter or bio_policy, Gemini's SAFETY (#248), +// and DeepSeek's content_filter: deepseek-v4.1-flash on WorkBuddy reasoned +// for 5s and then ended content_filter with nothing said (the plugin takes +// out the filter's canned line), and with its reasoning let through the +// group's next member was never asked and DeepSeek Harness failed "The +// model refused to complete the request" (itspig, plugins #540). +// Anybody else's reasoning — GLM's, Kimi's… — is shown as it comes: held, +// GLM on a ZCode account through a group showed Claude Code its thinking +// only once the text began, all at once (悠悠哥 on Discord). func refusesAfterThinking(model string) bool { if modelFamily(model) != "" { return true @@ -2278,7 +2283,7 @@ func refusesAfterThinking(model string) bool { if i := strings.LastIndex(m, "/"); i >= 0 { m = m[i+1:] } - return strings.HasPrefix(m, "gemini") + return strings.HasPrefix(m, "gemini") || strings.HasPrefix(m, "deepseek") } // scan reads the held stream's events so far: an error before any content diff --git a/internal/gateway/refusal_thinking_test.go b/internal/gateway/refusal_thinking_test.go index 5b5ef1756..66af6ad07 100644 --- a/internal/gateway/refusal_thinking_test.go +++ b/internal/gateway/refusal_thinking_test.go @@ -134,3 +134,59 @@ func TestThinkingHeldLonger(t *testing.T) { t.Fatal("reasoning held past holdThinking") } } + +// DeepSeek's filter refusing after it has reasoned, on WorkBuddy through +// a group (itspig, plugins #540): deepseek-v4.1-flash reasoned for ~5s, +// then ended finish_reason content_filter with 0 tokens counted, all under +// a 200. The plugin takes the filter's "Sorry, I can't respond to this +// question." out, so this is what reaches magpie: reasoning, then +// content_filter with nothing said. Its reasoning went through as it came, +// so the next member was never asked and DeepSeek Harness failed "The +// model refused to complete the request"; held, the next member answers. +// A DeepSeek reply that goes on to answer comes through whole. +func TestDeepSeekRefusalAfterThinkingFailsOver(t *testing.T) { + refused := sse(`data: {"id":"c1","object":"chat.completion.chunk","model":"deepseek-v4.1-flash","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":""},"finish_reason":null}]}`, + `data: {"id":"c1","object":"chat.completion.chunk","model":"deepseek-v4.1-flash","choices":[{"index":0,"delta":{"reasoning_content":"The user is asking"},"finish_reason":null}]}`, + `data: {"id":"c1","object":"chat.completion.chunk","model":"deepseek-v4.1-flash","choices":[{"index":0,"delta":{"reasoning_content":" about it."},"finish_reason":null}]}`, + `data: {"id":"c1","object":"chat.completion.chunk","model":"deepseek-v4.1-flash","choices":[{"index":0,"delta":{},"finish_reason":"content_filter"}],"usage":{"prompt_tokens":0,"completion_tokens":0,"total_tokens":0}}`, + `data: [DONE]`) + answered := sse(`data: {"id":"c1","object":"chat.completion.chunk","model":"deepseek-v4.1-flash","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"The user is asking"},"finish_reason":null}]}`, + `data: {"id":"c1","object":"chat.completion.chunk","model":"deepseek-v4.1-flash","choices":[{"index":0,"delta":{"content":"from a"},"finish_reason":null}]}`, + `data: {"id":"c1","object":"chat.completion.chunk","model":"deepseek-v4.1-flash","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":3,"completion_tokens":5,"total_tokens":8}}`, + `data: [DONE]`) + run := func(t *testing.T, up string) (*scripted, *scripted, *Server, int, string) { + fresh(t) + a := &scripted{replies: []reply{{200, "text/event-stream", up}}} + b := &scripted{replies: []reply{{200, "text/event-stream", anthropicAnswer}}} + scriptedOn(t, "a", provider.Chat, a) + pa, err := provider.Find("a") + if err != nil { + t.Fatal(err) + } + pa.Models = []string{"deepseek-v4.1-flash"} + if err := provider.Save(*pa); err != nil { + t.Fatal(err) + } + scriptedOn(t, "b", provider.Anthropic, b) + refusalGroup(t, "a/deepseek-v4.1-flash", "b/m") + s := New() + code, body := sendTo(s, "/v1/messages", claudeCodeAsk) + return a, b, s, code, body + } + t.Run("refused", func(t *testing.T) { + a, b, s, code, body := run(t, refused) + if code != 200 || !strings.Contains(body, "from b") || strings.Contains(body, `"refusal"`) || strings.Contains(body, "The user is asking") || a.n != 1 || b.n != 1 { + t.Fatalf("%d %s (a %d, b %d)", code, body, a.n, b.n) + } + r := lastRoute(s) + if len(r.Tries) != 2 || r.Tries[0].Fail != failRefused || r.Tries[0].Rest != nil || r.Status != 200 { + t.Fatalf("tries: %+v", r.Tries) + } + }) + t.Run("answered", func(t *testing.T) { + a, b, _, code, body := run(t, answered) + if code != 200 || !strings.Contains(body, "The user is asking") || !strings.Contains(body, "from a") || strings.Contains(body, "from b") || a.n != 1 || b.n != 0 { + t.Fatalf("%d %s (a %d, b %d)", code, body, a.n, b.n) + } + }) +} diff --git a/internal/gateway/thinking_streams_test.go b/internal/gateway/thinking_streams_test.go index f01a1270d..d7c9595f6 100644 --- a/internal/gateway/thinking_streams_test.go +++ b/internal/gateway/thinking_streams_test.go @@ -128,13 +128,14 @@ func TestThinkingStreamsThroughGroup(t *testing.T) { } // Claude's reasoning is still held for a refusal after it (#248) while -// another candidate could answer, and so are OpenAI's and Gemini's; -// anybody else's is let through. +// another candidate could answer, and so are OpenAI's, Gemini's and +// DeepSeek's (plugins #540); anybody else's is let through. func TestThinkingHeldFor(t *testing.T) { for model, held := range map[string]bool{ "claude-opus-5-5": true, "anthropic/claude-sonnet-4.5": true, "gpt-5.2-codex": true, "o3": true, "gemini-3-pro-preview": true, "models/gemini-2.5-flash": true, - "GLM-5.1": false, "glm-4.6": false, "deepseek-v4": false, "kimi-k2.5": false, "MiniMax-M2": false, + "deepseek-v4": true, "deepseek-v4.1-flash": true, "deepseek/deepseek-v4-pro": true, + "GLM-5.1": false, "glm-4.6": false, "kimi-k2.5": false, "MiniMax-M2": false, } { if got := refusesAfterThinking(model); got != held { t.Errorf("%s: held %v, want %v", model, got, held) diff --git a/internal/provider/migrate_workbuddy.go b/internal/provider/migrate_workbuddy.go index d52af6f81..6c8ddc079 100644 --- a/internal/provider/migrate_workbuddy.go +++ b/internal/provider/migrate_workbuddy.go @@ -16,7 +16,7 @@ func init() { for _, w := range []*wbSite{wbCN, wbAI} { movers[w.id] = &mover{ pkg: "@magpie-community/opencode-workbuddy-auth", - min: "0.2.3", // 0.2.3: an opening WorkBuddy refuses (11128) that FLAGGED does not know is sent once more with one more comma before the system prompt is moved, only in system and assistant messages, and a system prompt whose comma passed goes with it from the next chat on; a refusal that stands names REFUSED.md, where its fix is written (MYCF711, plugins #513); 0.2.2: DeepSeek Harness's opener goes as "You are an AI agent, powered by DeepSeek Harness.", which passes WorkBuddy's whole-line check (11128) and keeps the harness's name, where 0.1.27's neutral line took it out (MYCF711, plugins #511); 0.2.1: a sign-in to an enterprise account (a team, or 「WorkBuddy 教育公益版」, picked on WorkBuddy's sign-in page) is named "nickname · enterprise", so it no longer replaces the same person's personal account, which shares its uid and nickname (jwaitq on Discord, plugins b9cbb9d); 0.2.0: a WorkBuddy (China) account claims its daily check-in credits through the billing meter, as WorkBuddy's client does, and an API-key account reports itself ineligible for check-in instead of failing and being tried again every 30 minutes (plugins #177); 0.1.48: WorkBuddy AI's card shows the free model's daily token window, read from magpie's usage ledger (plugins #299); 0.1.47: a conversation's X-Conversation-ID and X-Conversation-Request-ID are one account's own (they hash the account too), so a session spread over a group of accounts no longer sends the same ids under every X-User-Id, which WorkBuddy's client, signed in as one account, never does (plugins 1e7122e, leaves5760 on Discord: a group's accounts restricted, not verified as the cause); 0.1.46: WorkBuddy AI's chats carry its current desktop client's headers, WorkBuddy/5.9.3 workbuddy-ai/5.9.3 CLI/2.165.0 with X-IDE-Version 5.9.3 and X-Agent-Runtime local-agent, not 5.8.4's (plugins b08a6c1); 0.1.45: only a chat completion goes gzipped, so magpie's drawings (the Magpie Image MCP, /v1/images/*) reach WorkBuddy's images API as plain JSON again, not 400 11101 "invalid character '\x1f'" (iwinux on Discord, broken since 0.1.43); 0.1.44: a 45 MiB chat's conversation and turn ids are hashed from its pieces, not from fresh copies of the whole message, and "Free models only" and a model that wants a reply after tools read the one parse too, so the repro's peak goes 717-760 to 583 MiB with every byte sent unchanged (plugins #461); 0.1.43: a chat that names no effort goes at the model's own default from WorkBuddy's config (DeepSeek-V4.1-Flash: high), as WorkBuddy's client sends it, so OpenCode's default variant thinks (troilus1011 on X); a chat goes gzipped, as WorkBuddy's client sends it, so the upload is the size the official client's is (runmiNeverstop on X, 2.89 GB up); 0.1.42: a chat is parsed once on its way, not once a step, and goes as it came when nothing changed it, so a 45 MiB chat no longer holds seven parsed copies in the plugin host (plugins #461, #4004); 0.1.41: a package with no cycle total (a prepaid wallet) is a balance window, "Prepaid credits", beside the share of packages that have one (plugins #450, #3950); 0.1.40: a chat carries the headers of each build's current desktop app: its CLI's User-Agent (WorkBuddy/ / CLI/, was WorkBuddy/5.5.6), X-IDE-Version, X-Agent-Type on both builds, X-Agent-Runtime on the China build, and the OpenAI SDK's X-Stainless headers, read from WorkBuddy 5.9.3 and WorkBuddy AI 5.8.4 (accounts restricted, a header-fingerprint check reported on X); 0.1.39: an earlier turn's reasoning_content (or reasoning_details text) goes as `reasoning`, as WorkBuddy's own client sends it, since WorkBuddy drops reasoning_content and Grok Build's history lost its thinking (uk.jent on Discord); 0.1.38: a "Free models only" switch lists only the free models and refuses any other before it is sent, so no credits are spent (plugins #430); 0.1.37: sign in with a WorkBuddy API key from the profile/keys page, sent as WorkBuddy's own client sends it (plugins #407); 0.1.35: used credits say when the plan's cycle starts again, as WorkBuddy's client does, so the card no longer reads "Not used yet" beside them (windy on Discord); 0.1.34: a free account's plan reads "Free plan" (plugins #337); 0.1.33: an untyped object oneOf goes to Kimi as type "object" (plugins #378); 0.1.32: plugins #346; 0.1.31: a 401 is renewed once, whatever the token's time, and sent once more; when the retry is refused too, the 401 says to sign in again (Providers → WorkBuddy → this account), and the account is marked expired only on WorkBuddy's word that the sign-in is gone (refresh token refused, or invalid_token with nothing to renew with) (wenchen855443 on X); 0.1.30: a refused line the model quotes back into an assistant message is reworded there too, so a long DeepSeek Harness chat isn't refused for good (plugins #291); 0.1.29: a system prompt WorkBuddy refuses as an unapproved channel (11128) is sent once more as the first user message's instructions, with WorkBuddy's default system prompt, since WorkBuddy checks only system and assistant messages; the refusal still rests no account (Wing on Discord); 0.1.28: a refusal of words not reworded yet ends in a hint that names no one client (plugins #279); 0.1.27: DeepSeek Harness's opening identity line is reworded to a neutral one, which WorkBuddy otherwise refuses as an unapproved channel (11128) (plugins #279, #280); 0.1.26: a model that says only supportsReasoning and a default effort lists low, high, max and that default, not "doesn't reason" (plugins #255); 0.1.25: WorkBuddy AI's fast, balanced and primary models keep the credit rate its config gives as "x0.34 credits", not unknown (plugins #216); 0.1.24: a refused sign-in on a chat over 2 MiB says the 401 and to sign in again: WorkBuddy's front door resets such a request instead of answering, so it read as 502 ECONNRESET (wyp on Discord); 0.1.23: credits used up leave the free models counted out of the credits window, so an account is not ranked spent for them (plugins #138); 0.1.22: an MCP server's tool schemas reach Kimi and DeepSeek: an enum with no type, or of several types, is typed, and true or false where a schema goes is {} or {"not": {}}, so they aren't 400 11133 "Invalid request parameters" (plugins #122); 0.1.21: a model free only at night (Hy4 preview) is never said free, and a whole-day discount shows the price before it, from WorkBuddy's modelPromotions (plugins #121); 0.1.20: tool results followed by the user's message reach WorkBuddy AI's gemini-3.8-flash, not 400 "the conversation must end with a user message" (plugins #113); 0.1.19: an enterprise account's card shows its credits, from the enterprise meter WorkBuddy's usage page reads (#1904); 0.1.18: WorkBuddy 5.6+ keeps its desktop sign-in encrypted, and the plugin says so and points to the browser sign-in instead of a 502 (plugins #18); 0.1.17: a restricted account's 403 11140 ends in provider.WBRestrictedHint, so it rests 2h as restricted (#1849); 0.1.16: WorkBuddy AI's GLM models are text-only, so magpie's image-describing model reads their images (Yirasumi on Discord); 0.1.15: a system prompt sent as a developer message passes the channel check, an object tool_choice is sent as WorkBuddy takes it, and max_completion_tokens goes as max_tokens so the cap holds (plugins #96); 0.1.14: the Credits window says when the soonest credits left run out, for Smart routing to spend them first (cdredfox on X); an enterprise account names its enterprise, so it lists and uses the enterprise's models, not the personal plan's (plugins #75); a chat's tools get shapes WorkBuddy AI's models take, so ZCode's and DeepSeek Harness's chats on deepseek-v4.1-flash aren't 400 "Invalid request parameters" (wyh on Discord); one user send is one request in the usage list: every step carries one X-Conversation-Request-ID, and both builds name the client (使用端) (plugins #48); credits used up (code 14018) say so, with the nested error message (plugins #25); Codex's and Claude Code's chats pass WorkBuddy's channel check (#182); a failure's status and its sign-in mark as the built-in's; each model's credit rate; the sign-in renewed ahead of time through auth.refresh; the credits' count beside their share (#659) + min: "0.2.4", // 0.2.4: a streamed chat that WorkBuddy's safety filter ends content_filter after its canned "Sorry, I can't respond to this question." has that line taken out, so the reply says nothing before the filter's stop and magpie hands it to the group's next member, not to the agent as an answer (itspig, plugins #540); 0.2.3: an opening WorkBuddy refuses (11128) that FLAGGED does not know is sent once more with one more comma before the system prompt is moved, only in system and assistant messages, and a system prompt whose comma passed goes with it from the next chat on; a refusal that stands names REFUSED.md, where its fix is written (MYCF711, plugins #513); 0.2.2: DeepSeek Harness's opener goes as "You are an AI agent, powered by DeepSeek Harness.", which passes WorkBuddy's whole-line check (11128) and keeps the harness's name, where 0.1.27's neutral line took it out (MYCF711, plugins #511); 0.2.1: a sign-in to an enterprise account (a team, or 「WorkBuddy 教育公益版」, picked on WorkBuddy's sign-in page) is named "nickname · enterprise", so it no longer replaces the same person's personal account, which shares its uid and nickname (jwaitq on Discord, plugins b9cbb9d); 0.2.0: a WorkBuddy (China) account claims its daily check-in credits through the billing meter, as WorkBuddy's client does, and an API-key account reports itself ineligible for check-in instead of failing and being tried again every 30 minutes (plugins #177); 0.1.48: WorkBuddy AI's card shows the free model's daily token window, read from magpie's usage ledger (plugins #299); 0.1.47: a conversation's X-Conversation-ID and X-Conversation-Request-ID are one account's own (they hash the account too), so a session spread over a group of accounts no longer sends the same ids under every X-User-Id, which WorkBuddy's client, signed in as one account, never does (plugins 1e7122e, leaves5760 on Discord: a group's accounts restricted, not verified as the cause); 0.1.46: WorkBuddy AI's chats carry its current desktop client's headers, WorkBuddy/5.9.3 workbuddy-ai/5.9.3 CLI/2.165.0 with X-IDE-Version 5.9.3 and X-Agent-Runtime local-agent, not 5.8.4's (plugins b08a6c1); 0.1.45: only a chat completion goes gzipped, so magpie's drawings (the Magpie Image MCP, /v1/images/*) reach WorkBuddy's images API as plain JSON again, not 400 11101 "invalid character '\x1f'" (iwinux on Discord, broken since 0.1.43); 0.1.44: a 45 MiB chat's conversation and turn ids are hashed from its pieces, not from fresh copies of the whole message, and "Free models only" and a model that wants a reply after tools read the one parse too, so the repro's peak goes 717-760 to 583 MiB with every byte sent unchanged (plugins #461); 0.1.43: a chat that names no effort goes at the model's own default from WorkBuddy's config (DeepSeek-V4.1-Flash: high), as WorkBuddy's client sends it, so OpenCode's default variant thinks (troilus1011 on X); a chat goes gzipped, as WorkBuddy's client sends it, so the upload is the size the official client's is (runmiNeverstop on X, 2.89 GB up); 0.1.42: a chat is parsed once on its way, not once a step, and goes as it came when nothing changed it, so a 45 MiB chat no longer holds seven parsed copies in the plugin host (plugins #461, #4004); 0.1.41: a package with no cycle total (a prepaid wallet) is a balance window, "Prepaid credits", beside the share of packages that have one (plugins #450, #3950); 0.1.40: a chat carries the headers of each build's current desktop app: its CLI's User-Agent (WorkBuddy/ / CLI/, was WorkBuddy/5.5.6), X-IDE-Version, X-Agent-Type on both builds, X-Agent-Runtime on the China build, and the OpenAI SDK's X-Stainless headers, read from WorkBuddy 5.9.3 and WorkBuddy AI 5.8.4 (accounts restricted, a header-fingerprint check reported on X); 0.1.39: an earlier turn's reasoning_content (or reasoning_details text) goes as `reasoning`, as WorkBuddy's own client sends it, since WorkBuddy drops reasoning_content and Grok Build's history lost its thinking (uk.jent on Discord); 0.1.38: a "Free models only" switch lists only the free models and refuses any other before it is sent, so no credits are spent (plugins #430); 0.1.37: sign in with a WorkBuddy API key from the profile/keys page, sent as WorkBuddy's own client sends it (plugins #407); 0.1.35: used credits say when the plan's cycle starts again, as WorkBuddy's client does, so the card no longer reads "Not used yet" beside them (windy on Discord); 0.1.34: a free account's plan reads "Free plan" (plugins #337); 0.1.33: an untyped object oneOf goes to Kimi as type "object" (plugins #378); 0.1.32: plugins #346; 0.1.31: a 401 is renewed once, whatever the token's time, and sent once more; when the retry is refused too, the 401 says to sign in again (Providers → WorkBuddy → this account), and the account is marked expired only on WorkBuddy's word that the sign-in is gone (refresh token refused, or invalid_token with nothing to renew with) (wenchen855443 on X); 0.1.30: a refused line the model quotes back into an assistant message is reworded there too, so a long DeepSeek Harness chat isn't refused for good (plugins #291); 0.1.29: a system prompt WorkBuddy refuses as an unapproved channel (11128) is sent once more as the first user message's instructions, with WorkBuddy's default system prompt, since WorkBuddy checks only system and assistant messages; the refusal still rests no account (Wing on Discord); 0.1.28: a refusal of words not reworded yet ends in a hint that names no one client (plugins #279); 0.1.27: DeepSeek Harness's opening identity line is reworded to a neutral one, which WorkBuddy otherwise refuses as an unapproved channel (11128) (plugins #279, #280); 0.1.26: a model that says only supportsReasoning and a default effort lists low, high, max and that default, not "doesn't reason" (plugins #255); 0.1.25: WorkBuddy AI's fast, balanced and primary models keep the credit rate its config gives as "x0.34 credits", not unknown (plugins #216); 0.1.24: a refused sign-in on a chat over 2 MiB says the 401 and to sign in again: WorkBuddy's front door resets such a request instead of answering, so it read as 502 ECONNRESET (wyp on Discord); 0.1.23: credits used up leave the free models counted out of the credits window, so an account is not ranked spent for them (plugins #138); 0.1.22: an MCP server's tool schemas reach Kimi and DeepSeek: an enum with no type, or of several types, is typed, and true or false where a schema goes is {} or {"not": {}}, so they aren't 400 11133 "Invalid request parameters" (plugins #122); 0.1.21: a model free only at night (Hy4 preview) is never said free, and a whole-day discount shows the price before it, from WorkBuddy's modelPromotions (plugins #121); 0.1.20: tool results followed by the user's message reach WorkBuddy AI's gemini-3.8-flash, not 400 "the conversation must end with a user message" (plugins #113); 0.1.19: an enterprise account's card shows its credits, from the enterprise meter WorkBuddy's usage page reads (#1904); 0.1.18: WorkBuddy 5.6+ keeps its desktop sign-in encrypted, and the plugin says so and points to the browser sign-in instead of a 502 (plugins #18); 0.1.17: a restricted account's 403 11140 ends in provider.WBRestrictedHint, so it rests 2h as restricted (#1849); 0.1.16: WorkBuddy AI's GLM models are text-only, so magpie's image-describing model reads their images (Yirasumi on Discord); 0.1.15: a system prompt sent as a developer message passes the channel check, an object tool_choice is sent as WorkBuddy takes it, and max_completion_tokens goes as max_tokens so the cap holds (plugins #96); 0.1.14: the Credits window says when the soonest credits left run out, for Smart routing to spend them first (cdredfox on X); an enterprise account names its enterprise, so it lists and uses the enterprise's models, not the personal plan's (plugins #75); a chat's tools get shapes WorkBuddy AI's models take, so ZCode's and DeepSeek Harness's chats on deepseek-v4.1-flash aren't 400 "Invalid request parameters" (wyh on Discord); one user send is one request in the usage list: every step carries one X-Conversation-Request-ID, and both builds name the client (使用端) (plugins #48); credits used up (code 14018) say so, with the nested error message (plugins #25); Codex's and Claude Code's chats pass WorkBuddy's channel check (#182); a failure's status and its sign-in mark as the built-in's; each model's credit rate; the sign-in renewed ahead of time through auth.refresh; the credits' count beside their share (#659) agents: []string{w.id}, out: func() ([]Moving, error) { var out []Moving