Files
magpie/docs
yetoneandSma1lboy d1f0576a78 gateway: a Claude run kept again leaves its old key, so letting go past idleMost ends instead of spinning with the bridge locked (X, Sma1lboy)
Sma1lboy found magpie at 158 GB after two days with many omp agents on a
Claude subscription, and traced it to keepIdle.

Cause: letGo keeps a run at backKey when the client goes away mid-reply,
and the reply's ended can then keep the same run at the turn after. The
run sat in b.idle under both keys. Past idleMost, the eviction loop picked
that run as oldest on every pass but deleted only run.idleKey (the newer
key, then ""), so len(b.idle) never fell: the loop never ended, held b.mu
(stopping every Claude subscription request) and appended to drop
without bound.

Fix: keeping a run again removes its earlier entry when that entry is
still its own (not a run that replaced it), and the eviction loop deletes
the map key it found as oldest, aborting each run once.

Run: go test -tags nogui ./internal/gateway/ (ok, 396s); gofmt -l clean;
GOOS=linux and GOOS=windows go vet ./internal/gateway clean. The new
TestClaudeIdleRunMoves and TestClaudeIdleEvictionEnds (rekey and stale,
in a child process) fail on the old keepIdle: the child times out in the
loop. Not reproduced with a real two-day omp workload.

Co-authored-by: Sma1lboy <541898146chen@gmail.com>
2026-10-11 19:10:43 +08:00
..