Files
magpie/docs
yetone ab3fe0fe41 gateway: a Claude subscription turn whose saved session Claude Code can't load goes on in a new Claude Code instead of 502 "Claude Code ended", and a Claude Code that ends early says why (FrierenF on Discord)
What: a conversation let go past idleMost is resumed from its saved
session (unshelve, `claude --resume <sid>`). Claude Code 2.1.295 that
can't load the session prints "No conversation found with session ID"
and exits 1 before it reads anything, without answering a control
request (tried with the real binary in a scratch CLAUDE_CONFIG_DIR: a
missing and an empty session file both do this; a loadable one answers
initialize). With the safety context set (Claude Code's auto mode),
start's initialize got its reply channel closed and the turn was
answered 502 "Claude Code: Claude Code ended", with no reason; without
it, the turn got an empty 200.

Now:
- start sends initialize to a run resumed from a saved session too, as
  the probe that Claude Code loaded it; when that run fails, the session
  is let go and a new Claude Code is told the whole conversation in the
  same request (start / startRun).
- cliControl reports a run that ended before answering with its exit
  status and stderr tail (endedBefore, shared with whyEnded), and its
  timeout no longer says "safety context" for every request.
- The other paths that can meet an ended run already start a new one:
  resume (setSafeguards / tell failing -> abort, fall through) and the
  tool-results path (claimResume / continueWith -> runExpired).
- The resume harness's fake Claude Code now acknowledges control
  requests as Claude Code does.

Not known: why FrierenF's saved session couldn't be loaded, or whether
their run ended for another reason; their next failure will now name it.

Run:
- TestClaudeUnloadableSessionStartsAnew (both with and without
  safeguards) and TestClaudeEndedRunSaysWhy fail on origin/main:
  "502 Claude Code ended"; no run started anew (empty 200);
  "Claude Code: Claude Code ended" lacks exit status 3 and stderr.
  They pass with the change, -race -count=10.
- go test -tags nogui ./internal/gateway/ under a temp HOME, pinned
  caches: ok (174s).
- gofmt -l clean; go vet (darwin), GOOS=linux go vet -tags nogui,
  GOOS=windows go vet (with and without nogui) for internal/gateway;
  go build, GOOS=linux go build -tags nogui, GOOS=windows go build: ok.
- Not run: a real signed-in Claude account (no credentials copied), the
  Windows box, the rest of the repo's packages.
2026-10-09 22:29:41 +08:00
..