CI on b75e21be3 (ubuntu, run 38549121391) failed group_replan: the last
try ended 499 "canceled" after 112ms with Again 0, so the agent had left
while the try was still in flight, not in the pause the test is about.
The test counted the upstream's request and then slept a fixed 100ms
before cancelling; on a loaded runner the gateway hadn't read the 503 by
then. It now polls the trace until the last route has its tries and the
last one carries Again (written just before the pause starts), then
cancels.
Run (worktree on origin/main 331c27703):
- Injected a 150ms sleep in the fake upstream between counting and
answering: the old test fails both subtests with CI's exact shape
(Millis ~110, Again 0); the new one passes, -count=3.
- Break check: with try.Gone = true taken out of both pause paths in
gateway.go, the new test fails both subtests.
- go test -race -run TestAgentGoneInTheRetryPause -count=8: ok (116s,
load average ~300).
- gofmt -l clean, go vet -tags nogui ./internal/gateway ok.
Not run: the whole gateway package (only this test file changed).
heng91's relay was unreachable while their proxy was off; magpie answered
the relay's 503 with its short same-one retry (or a group's replan), and
they closed the Claude Code / Codex window in the pause. The gateway
already stopped there: the pause selects on the request's context, the
route ended with 499 and the upstream was asked nothing more. But the
trace never said so: the last try kept only its Again, so the Routing
page's story ended on "... it is tried again in 2.0 s" and the list said
"499 · failed", which reads as the closed session still retrying.
- gateway: the three pauses (the last one left asked again, the same
after spentAfter, and the group's replan through pauseAlive) mark the
try whose pause it was `Gone` when the agent leaves in it.
- Routing page: such a try says the agent canceled the request before the
retry and nobody is asked again (en, zh, zh-TW, ja, de); the request
list and the outcome label say canceled; the replay's dot goes home.
- docs/subsystems/gateway-routing.md says so.
Reproduced first with a fake upstream (httptest) answering 503 and one
hanging, a real gateway server and a client that disconnects: single
provider, group replan, streamed and not, hang mid-try. In every case the
route ended at once with nothing in flight and the upstream saw no
further request (the hanging one saw its request canceled); only the
trace's last line was wrong. The plugin fetch path already sends the
host an abort on cancel (host.js "abort").
Run:
- TestAgentGoneInTheRetryPause (new, -race): agent leaves in the pause,
single and group; upstream count stays, route done 499, no try in
flight, last try Gone. Red with the Gone marking removed (Gone false),
and red with the pauses ignoring the context (route not done).
- routing-agent-gone.test.cjs (new): Chromium and WebKit, en/zh/ja/de,
1100 and 420 wide, 16/16; red (0/4) with the story and label change
reverted.
- go test -tags nogui ./internal/gateway ./internal/gui; routing-*,
rest-try-now and ledger-retried GUI tests on both engines; gofmt -l;
GOOS=linux and GOOS=windows go vet -tags nogui on both packages.
Not tried: the reporter's own relay and proxy, or a real Claude Code /
Codex window closed mid-pause.
The one other red in that GUI run, routing-wb-restricted at 420 in
Chromium under the full run (passes alone 3/3), is filed as #1905.