ac4af582301a4e8a29245dbba767eba31334ddf9
9
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
0a5dc40abc |
gateway: a group's trusted Claude, GPT and Gemini thinking streams as it comes, a refusal or error after it going to the next member (#4166)
A try whose model's vendor may refuse after its reasoning (#248) had its reasoning held while another candidate could answer, whatever the member had answered lately. Through a routing group Claude Code saw a Claude member's thinking only with its text, all at once, and never its "thinking with <effort> effort". waynesguan measured it on one WorkBuddy account: `workbuddy claude-opus-5.5` alone, first thinking at 3.66s; through the group, all 67 thinking deltas with the text at 17.25s. Ported from waynesguan's 71aacaa (on |
||
|
|
e89a4b3c77 |
gateway tests: a re-asked slowThinker drops its done send instead of blocking (#4530)
slowThinker.done held one send, and a try that is asked again serves the same fake vendor a second time: the second handler blocked on the send forever, the reply it served never ended, and t.Cleanup(vendor. Close) waited on it until go test's own timeout — no test failure, no output, the whole package with it (#4530). The tests read the time once; later sends can drop (Jackzigen's fix in gh#4530, adopted): the send is non-blocking, and TestThinkingVendorAskedAgainStillEnds, which asks a Gemini fake that only reasons and whose reply is asked again in place (#667), reads the reply to its end instead of hanging. Squashed from the patch's two commits (test, then fix), so no commit on main hangs the package. Broken by hand: with the blocking `s.done <- time.Now()` put back, TestThinkingVendorAskedAgainStillEnds hangs until -timeout 120s panics, with a serve stuck at thinking_streams_test.go:40. With the patch it passes in 1.4s, and -race -count=20 is ok. Co-authored-by: Jackzigen <9687529+Jackzigen@users.noreply.github.com> |
||
|
|
645eb92f3f |
gateway: a refusal after shown thinking goes to the next fallback
yhwangl on X: a request whose content trips a vendor's safety filter after the model streamed its thinking, before any answer, stopped there; the group's next member was never asked, as it is when credit runs out. When a model's reasoning is shown, a try passes on its first thinking event, so a refusal after it was the agent's. Now, for a streamed Anthropic, Chat or Responses request with another member still to ask (handsOver), the try's events go out one by one (passOver) and a refusal or refusal error before any text or tool call hands the request on (handOver): Anthropic's open blocks are closed and the next member's stream is spliced into the same reply (spliceAfter): its message_start or response.created/in_progress/queued are dropped, block indexes or output_index go after those sent, sequence_number goes on. Chat chunks go as they come. Once text or a call has gone, a refusal stays the agent's as before. With no other member nothing changes. A refusal is about the request, so nobody is rested for it. Zhipu's finish_reason "sensitive" and error 1301 (敏感), DashScope's data_inspection_failed and Volcengine Ark's *SensitiveContentDetected are now read as refusals too. Not covered (#4604): Gemini clients; a Responses reasoning item handed over gets no output_item.done and the next completed lists only its own output; A's thinking signature stays in the reply; non-streamed requests. Run (mote, worktree at base |
||
|
|
6585315e32 |
gateway: a DeepSeek member's reasoning streams through once it has answered cleanly three times running (#4512)
|
||
|
|
c8f199695c |
gateway: DeepSeek's reasoning is held for a refusal after it; WorkBuddy plugin min 0.2.4 (plugins #540)
itspig (plugins #540): deepseek-v4.1-flash on WorkBuddy, through group/tiered, reasoned ~5s, said "Sorry, I can't respond to this question.", and ended finish_reason content_filter with 0 output tokens under a 200. The try was recorded done/200, none of the 15 members behind it was asked, and DeepSeek Harness failed "The model refused to complete the request". Two halves: - workbuddy 0.2.4 (plugins 4883f94) takes the filter's canned line out of a streamed chat that ends content_filter with nothing else said. - refusesAfterThinking now holds DeepSeek's reasoning too (as Claude's, GPT's and Gemini's), only while another candidate could answer: with it let through as it came, a refusal after it could never go to the next member. DeepSeek's own API documents finish_reason content_filter. The cost: in a group with a member behind it, DeepSeek's thinking reaches the agent once its text begins (kept alive meanwhile), as Claude's does; on the last candidate it streams as before. GLM, Kimi and others are unchanged. - The workbuddy mover's min is 0.2.4 (npm view --prefer-online: 0.2.4). Run on mote at this tree: go test ./internal/gateway -run 'TestDeepSeekRefusalAfterThinkingFailsOver|TestThinkingHeldFor| TestRefusalAfterThinkingFailsOver|TestThinkingStreams' ok; go test ./internal/provider ok; gofmt -l clean. The full ./... suite was started at this tree minus the one-line min and is still running; its result goes on plugins #540 (owner rule: tag without waiting). Broken by hand: without the deepseek prefix, TestDeepSeekRefusalAfterThinkingFailsOver/refused goes red (DeepSeek's reasoning reached the agent, b never asked) and TestThinkingHeldFor red for the three DeepSeek ids; /answered stays green. Not tried: a real WorkBuddy refusal (no prompt reproduces it on demand); the upstream's literal chunking isn't in the issue, so the fixture is built from its fields (reasoning, content_filter, 0 tokens). |
||
|
|
592899467b |
gateway: Gemini's reasoning streams as it comes on the last candidate, so Codex isn't left with nothing for the whole of its thinking (LuckymanJC on Discord)
LuckymanJC and kkgg: through magpie the first turn of a Codex session on a Gemini model was very slow or seemed stalled. Measured with fake upstreams through the gateway (Codex Responses -> Chat DeepSeek, Gemini; OpenCode Chat; Anthropic passthrough), first content came within 1-50ms on every path but one: a Gemini model's reasoning was held even on the last candidate (`|| last && modelFamily(c.model) != ""` left Gemini out), so Codex got nothing at all, not even response.created, until the text began, while Claude's and GPT's has gone as it comes there since iTianbao's report. It was held there for #667, a reply that only reasoned being asked again. That re-ask happens in place in streamTranslated, keeping the reasoning the agent has, so it doesn't need the hold. But with the try passing, emptyRetries counted it as past the request's own re-asks and asked only streamRetries (2) times, and TestGeminiEmptyRepliesAskedAgain (three empty replies running) went red. A held try that went through on its reasoning alone (holdWriter.thoughtThrough) is now asked once more in place (streamRetries+1); a never-answering model still makes at most 4 calls (the test's bound is 6). Tests: TestThinkingStreamsWithNoOneElse gets "gemini" (Gemini upstream) and "chat gemini" cases, to Claude Code and Codex. With the old line restored they go red ("thinking held: first thought only 1.75us before the text"). With emptyRetries' new branch broken by hand (streamRetries+0), TestGeminiEmptyRepliesAskedAgain goes red with "an empty reply"; green with both. Run: go test -run 'TestGeminiEmpty|TestThinkingStreams|TestThinkingHeld|TestUncountedEmpty|TestReasoningLoop' ./internal/gateway: ok. Break check repeated at push: the old `|| last && modelFamily(c.model) != ""` turns TestThinkingStreamsWithNoOneElse/{gemini,chat_gemini}/v1/{messages,responses} red ("thinking held: first thought only 1.458µs before the text"). Full suite (go1.26.8 darwin-arm64, rebased on |
||
|
|
8b89b2e36c |
tests: two waits that went red at load 80–100 leave room: the reasoning relay is timed by the vendor's clock, otel waits a minute for its export
Both went red in full runs of go test ./... on a machine at load 80–100.
Neither is a fault in what they test.
- TestChatReasoningRelayedAsItComes: "first thought after 924ms" against a
700ms bound from before the request, while the thought still came ~1s
ahead of the text. The bound timed the gateway's start, not the relay.
slowThinker now records when it wrote each event. The test checks that
the first thought reached the client before the vendor wrote the text.
That is the guarantee, and a slow start no longer counts against it.
- plugins/otel TestOnExportsOffSendsNothing waited 10s for the first export.
It now waits a minute, as other waits for a plugin's first work do.
Run: go test -count=5 for the relay test, all ok. Broken by hand:
refusesAfterThinking returns true, so the reasoning is held as Claude's is.
The test went red ("reached the client 489µs after the vendor wrote the
text"). Full go test ./... ran with the middleware point commit before this
one (see its body).
|
||
|
|
76321e3b42 | gateway: a lone provider's Claude or GPT reasoning streams as it comes, not held for a refusal no one else could answer (iTianbao on X: 请加一个开关,让思考实时透传; through a relay Claude Code showed the thinking only all at once with the text, Codex none until then) — holdWriter held Claude's, GPT's and Gemini's reasoning (refusesAfterThinking, up to holdThinking) on every candidate, so a refusal after it could go to the next one (#248), but a refusal on the last candidate is never asked again (the !last checks in serve), so there it only delayed the thinking. On the last candidate Claude's and GPT's reasoning is now shown at once (thinkingShown), and a refusal after it reaches the agent as the vendor's own stop; Gemini's stays held there, for a reply that only reasoned to be asked again (#667, TestGeminiEmptyRepliesAskedAgain). A group with members after it still holds as before. Before: on a slow fake relay (4 thoughts 300ms apart, then text) every relay shape (Messages, Chat with reasoning_content and reasoning, Responses) for claude-sonnet-4-5 and gpt-5.1 gave Claude Code's thinking_delta and Codex's reasoning_summary_text.delta all at ~1.2–1.5s with the text; after, 0/300/600/900ms. TestThinkingStreamsWithNoOneElse (Messages, Chat for Claude and GPT, Responses; each asked from /v1/messages and /v1/responses) fails without the change in every case and passes; TestHeldThinkingKeepsTheAgentAlive's nobody-left case now expects the thinking and Claude's refusal rather than a held error. -race -count=5 on TestThinking*, TestRefusal*, TestHeld*, TestGeminiEmpty*; go test -tags nogui ./internal/gateway, go vet, gofmt -l, linux and windows (nogui) builds pass. Not tried with the reporter's relay: whether it sends GPT's reasoning at all (OpenAI's Chat API doesn't) is unknown, and no switch was added. docs/subsystems/gateway-routing.md says it. | ||
|
|
2fc277de9f |
gateway: GLM's thinking streams again through a group (悠悠哥 on Discord: ZCode's thinking shows only at the end, all at once) — since a8f0baaa (#248) a stream that had only reasoned was held, up to 4 minutes, until its text or a call began, for a refusal after the reasoning to go to the next account; so GLM on a ZCode account (or any key with retries left, or any group member before the last) showed Claude Code its thinking only once the text came, in one burst. Only Claude's, OpenAI's and Gemini's safety filters end a reply that has only reasoned with a refusal, so reasoning is now held only for those models (claude-*, gpt-*/o-series/codex, gemini-*); anybody else's (GLM, DeepSeek, Kimi, MiniMax…) goes through as it comes, as before #248. Requests, headers and prompts are unchanged. TestThinkingStreamsThroughGroup (a fake vendor streaming three thoughts 200ms apart, on Anthropic's API and on Chat with reasoning_content, read by a real HTTP client through a group) and TestThinkingHeldFor fail without the change; TestRefusalAfterThinkingFailsOver now names Claude and GPT models and still passes. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass.
|