Commit Graph
1 Commits
Author SHA1 Message Date
yetone 9730e01992 claude: a reply the client keeps as several text blocks goes on in its run (#5705)
A run is kept idle under a key hashed from the conversation with its
reply as the one text it said (every text event run together). The
Anthropic encoder closes a text block at any other event: a thinking
block, a web search, cited text, an attempt Claude Code asked again. So
the client holds the reply as several text blocks and sends them back
that way. messageWords joined parts with a space, so the client's reply
read "Looking at it: Here" where the run's read "Looking at it:Here".
The keys differed, the loose-turn check failed too, and the next turn
logged "no run waits for this turn: no run here has had this
conversation". It was then told to a new Claude Code from a transcript,
which wrote the whole conversation to the cache again (jerrychoi: ~706K
tokens 56s after a cold rebuild, with the first run still alive).

The words hashed for a message now hold no whitespace. Where the client
spaces or splits its text no longer counts, for the turn key, the
conversation keys and the loose turn alike. lostMedia reads per-part
words (messageParts), which are unchanged.

Run (on mote, through mote-run, at b657a2121 + this change):
- go test -count=1 -timeout 45m ./internal/gateway: ok (890s)
- go test -run TestClaudeReplySplitIntoBlocksGoesOnInItsRun -count=3: ok
- GOOS=linux go vet ./internal/gateway, GOOS=windows go vet
  ./internal/gateway: clean; gofmt -l: clean

Broken by hand: with the old messageWords, the new test is red with the
reporter's exact line, "claude: no run waits for this turn: no run here
has had this conversation", followed by "a new Claude Code is told the
whole conversation: 3 messages".

Not tried: the reporter's own reply structure is not known. It may have
been thinking between texts, a web search or citation, or a retried
attempt; the issue asks for the block types. No real Claude account was
used. The test skips on Windows (a shell script stands in for Claude
Code). No full ./... run: the change is confined to internal/gateway.

Reported-by: jerrychoi
2026-11-08 22:01:34 +08:00