Commit Graph
4 Commits
Author SHA1 Message Date
yetoneandggbdpq cc93b566e2 gateway: Zed's test still checks is_error true on a real result, beside the mended orphan (#1558)
What changed: d1d45dd3 made TestZedToolResultSaysIsError's toolu_2 result
an orphan turned to text, and its assertion went from [false true] to
[false]: nothing checked any more that a result with is_error true goes
to Zed's cloud with it (yetone/magpie-releases#9). The fixture's
assistant now makes toolu_2's call, so both real results keep [false
true], and a separate toolu_9 result with no call checks the orphan goes
as its text. The pairing tests also check the synthetic result is
is_error, and a new TestMessagesSecondAnswerDropped checks a call answered
twice keeps only its first answer. docs/subsystems/gateway-routing.md gets a bullet for the Messages build's mending, beside the Gemini and Responses ones.

Why: the patch's tests passed with is_error dropped from the synthetic
result and with the second-answer rule removed.

Run (sandbox HOME, private GOCACHE):
- go test -tags nogui -run 'TestMessages|TestZed' ./internal/gateway/: ok
- pairToolBlocks call removed: the six TestMessages tests and
  TestZedToolResultSaysIsError fail ("is_error: [false true false]",
  "what the lost result said is not kept").
- IsError dropped from the synthetic result: TestMessagesUnansweredCall
  GetsSyntheticResult fails. The duplicate's continue removed:
  TestMessagesSecondAnswerDropped fails ("user[A,A]").

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-13 06:43:00 +08:00
ggbdpqandfactory-droid[bot] e21b1dbc16 gateway: a broken tool exchange a Chat or Zed client left is mended for a Messages upstream, as the Chat and Responses paths mend theirs
What changed: buildAnthropic (every request built for a Messages
upstream: a Chat or Responses client's conversation translated, Zed's
bridge) now runs its messages through pairToolBlocks, as buildChat's
pairToolMessages (#554) and the relayed Responses path's pairToolItems
(#1341) mend theirs. Anthropic refuses a tool_use the next message's
tool_results don't answer ("`tool_use` ids were found without
`tool_result` blocks immediately after") and a tool_result naming a call
it never saw ("unexpected `tool_use_id` found in `tool_result` blocks");
an interrupted turn leaves the first behind, a client that dropped a
call the second. A call left unanswered gets the synthetic result the
other paths make; an answer to no call becomes a text block keeping
what it said. A well-formed exchange is built exactly as it was (ids in
their places, results in the order the client sent, text after them).

TestZedToolResultSaysIsError's fixture carried a result for a call the
request never made; it asserted the orphan went through as a
tool_result, which the cloud refuses. It now goes out as the text it
said, and the test says so.

Run:
- /tmp/sbx.sh test -tags nogui -count=1 -run 'TestMessages' ./internal/gateway/
  with the pairing call taken out: 6 FAIL (trace "user assistant(A)",
  and the end-to-end one 400 "unexpected `tool_use_id` found in
  `tool_result` blocks"); with it back in, all pass
- /tmp/sbx.sh test -tags nogui -count=1 ./internal/gateway/ — ok
- gofmt -l (nothing), go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... (the trayimage_darwin.go -Wenum-conversion
  warning as on main), go build, GOOS=linux go build -tags nogui,
  GOOS=windows go build

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-10-13 06:43:00 +08:00
yetone 3810dc3f8c zed: every tool result sent to Zed says is_error, false as well as true, so a turn after a tool call is answered again (yetone/magpie-releases#9, aurevae: "Zed: failed to parse Anthropic request: missing field is_error" on Pi through /v1/chat/completions and on /v1/messages) — magpie's Anthropic request leaves is_error out when it is false, as Anthropic's API allows, but Zed's cloud refuses a tool result without it, so with a Zed account every request after the model's first tool call failed with a 400. The reporter's own table shows the same request going through with is_error true. Zed's Anthropic request now has is_error on each tool_result; the tool inputs' numbers are kept as they were. TestZedToolResultSaysIsError checks a successful and a failed tool result, and a 20-digit number in a tool's input; it fails without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass (TestDevinSignedInOnlyInMagpie, a known flake under load, passes alone). 2026-09-30 15:53:29 +08:00
yetone 28396deabd zed: a Zed subscription (Pro, Student, Business) signed in from magpie, several accounts, served through Zed's own cloud (yosocoli5 on X: 买了 Zed 订阅,可以加进供应商吗 — yetone: 当然可以!) — magpie had no way to use Zed's hosted models. Zed is now a subscription in the add sheet (Zed's own logo from zed-industries/zed, lobe-icons has none), signed in as the Zed editor signs in (new internal/zed, the protocol): an RSA key is made, the browser opens zed.dev/native_app_signin with its PKCS#1 public half, magpie's loopback port and a system id, and comes back with user_id and the access token encrypted to the key (OAEP SHA-256, PKCS#1 v1.5 also read), answered with a redirect to zed.dev's succeeded page. The account is asked of /client/users/me (signed "<uid> <token>" with x-zed-system-id), kept with its GitHub login, its default organization and plan; an organization with hosted models turned off is refused. Several accounts can be added and switched like the other subscriptions. Requests get an LLM token from /client/llm_tokens (kept in memory, minted again when Zed answers 401 or x-zed-expired-token/x-zed-outdated-token, once; a refused pair marks the account lapsed, "sign in again"). The model list is Zed's /models for the account (disabled and unknown providers left out; context, output, images and effort levels kept). The gateway asks cloud.zed.dev/completions in Zed's envelope {provider, model, provider_request}, the request written in the model's own provider's API as Zed writes it — Anthropic Messages without stream, OpenAI Responses, xAI chat completions with max_completion_tokens, Gemini's request with models/<id> — and reads the NDJSON reply's events with that API's decoder: a failed status is an error with its status (upstream_http_N, rate limit 429, overloaded 529, payment 402), a reply without stream_ended is an error, not a shorter answer, a 402 says the plan doesn't include hosted models or its allowance is used up. relayQoder's status-keeping relay is now relayStatus, shared by Qoder and Zed. Usage shows the plan and its period's end; Zed reports no usage counter, so no windows. Signing in says first, as Antigravity's does, that Zed serves these models to its own editor and may treat magpie's use as third-party use (en and zh); the import box now uses a subscription's own risk note too. Tested in Go against fake zed.dev/cloud.zed.dev servers, no real account: internal/zed TestSignInKey, TestParseModels, TestReadLines; provider TestZedSignIn (the whole sign-in through the loopback callback, what is kept, the account and its models, the token kept and renewed, the quota's plan and end, a refused pair lapsing) and TestZedFreePlanQuota; gateway TestServeZedProviders (each of the four providers, streaming and not), TestServeZedFailures (stale token retried once, 402, upstream 529 with retry_after, a failed 429, cut short → 502), TestZedRequestShapes. New zed-sub.test.cjs in Chromium and WebKit, en and zh: the Zed row with its plans and logo, the risk note in Zed's words with nothing asked, then Sign in anyway asking for zed. add-sheet, add-button, old-webkit, signin-callback and own-signin-remove pass. go vet, go build -tags nogui (and GOOS=linux, GOOS=windows) and go test -tags nogui ./... pass. Not tried with a real Zed account: the sign-in page's real callback, the LLM token and completions endpoints' acceptance of magpie's headers, and each provider's real event shapes are from Zed's source, not seen on the wire. 2026-09-30 03:19:19 +08:00