heyusaku6 on X: Codex desktop thought for over ten minutes on a model
served through magpie (a routing group's DeepSeek, then Qoder CN's
MiniMax, then GPT-6.1 Sol), the Routing page showed none of them, and
only restarting Codex and magpie ended it. Codex waits for a reply's
headers with no limit of its own, and a request shows on the Routing
page only once a route is begun for it, so whatever held these requests
held them before routing, in silence.
The root cause was not found. Every pre-route wait read (the classifier,
image description, plugin GatewayBegin, JS middleware, provider.Hold,
the body read, pluginrt.Refresh, the trace lock) has a bound or follows
the request's context. So this makes the stall visible and bounded
instead, and records where it was held:
- counted watches an agent's turn (Chat, Responses, Messages, Gemini
generateContent, Codex backend /responses) while no route is begun for
it (unrouted.go). After 15s a route of provider "magpie" shows it on
the Routing page as routing; it gives way to the request's own route
when one begins (noteRoute, trace.drop).
- After 2m with no route and nothing written, the client is answered
504 in its own protocol, whole (Content-Length, Connection: close) so
it has the error even if the handler stays stuck. The request's
context ends with errUnrouted, its route ends with the error, and the
log gets every goroutine's stack (at most once in 10 minutes), which
says what held it next time.
- The handler writes through heldWriter, which drops its writes once
magpie has answered for it.
A request waiting on another request's identical image description for
over 2m is now answered 504 too; the retry finds the description cached.
Run in the worktree at origin/main 5df62c5cd + this change:
- The stall was injected as an image description in flight that never
ends (a never-closed s.sights entry), which holds pastedImage inside
serve before beginFor. TestUnroutedRequestShownThenAnswered and
TestUnroutedShownGivesWayToItsRoute are red with the watch unhooked
from counted (the request never shows; the client waits out its 20s
timeout) and green with it; the log's stack names describe at
vision.go:319 under seenBody.
- go test -race -count=3 on TestUnrouted|TestVision|TestEndBroken|Busy|
Concurrency|Trace: ok.
- gofmt -l clean; go vet ./internal/gateway on darwin, linux -tags nogui,
windows: ok.
- go test ./internal/gateway -timeout 45m -count=1: ok (537.9s)
Rebased onto 2f44e075a (internal/agent only); at that head go build ./... and TestUnrouted: ok.
Not run: the full ./... suite (another session's full suite was running
on this machine); a real Codex desktop on Windows.