skygunner (#4258): Claude and Codex unroute took the stashed originals
out of the stash before the config write that puts them back, so a write
that failed (a full disk, a file a watcher held) lost them for good, and
a retry had nothing to put back. The same shape was in Claude's
putClouds, and the model's original was taken out before the write that
restores or replaces it, which comes after unroute.
The originals are read with peek and taken out by forgetValues only once
the write has gone through, each only while it is still the value peeked:
one a concurrent change wrote since stays stashed. The model stays stashed
for the caller: Unwire takes it out after its write, and picking a model
of the agent's own after it.
A file that doesn't parse is copied aside before it is written over, as
it was (lastgood.KeepUnparsed); a change reports nothing new. The same
take-out-before-put-back shape in the other agents' restore paths (agy,
antigravity, cline, claudedesktop, astrbot) is left as it is.
Run (worktree at base a8fa771a6):
- go test ./internal/agent -run TestDisconnectFailureKeepsStashedOriginals:
ok, both computers; broken by hand: forgetValues called before the
write (claude, injected) puts the failure back
- go test ./internal/agent: ok
- gofmt -l: clean; go vet ./internal/agent: clean
Generated-by: GLM-5.3-Flash (ZCode)