Commit Graph
1 Commits
Author SHA1 Message Date
yetone d70f422043 gateway: a conversation of pictures keeps its text and pictures in Routing and Sessions (#5407)
matrix0487 on Discord: since images go to DeepSeek by file id, the
Routing card shows no pictures and the Sessions page loses the turns.

Cause: the views keep the body as the agent sent it, with every
picture inline, and they cap it. The Routing card keeps a body of up
to 32 MiB (promptBodyMax), and its archive read refuses a larger one.
A gateway-recorded turn keeps 8 MiB of input (conversationBodyMax),
and cutting it there leaves JSON that doesn't parse. Before #5407,
DeepSeek refused more than 64 MiB inline, so a conversation never got
far past these caps. With file ids it does: the reporter's turns send
about 30 MB of pictures each. The card then says the text is gone and
draws nothing, and the Sessions turn keeps only the reply.

Fix: leanImages swaps each inline picture's base64 (a data:image/...
URL, or a bare Anthropic or Gemini source that starts as a PNG, JPEG,
GIF or WebP does, 1 KiB or more, with no escapes) for a short ref
before the caps apply.
- Routing card: the kept body and the archive's copy (before its cap)
  keep their pictures in keptImages. It is memory only and bounded:
  128 MiB, least recently used first, and the same picture is kept
  once. dataImage reads a ref back to the data: URL. A ref whose
  picture has gone draws nothing.
- Sessions: the recorded input drops the base64 outright, since the
  page shows a picture as [image].
What goes upstream, what the archive stores, and the Recent calls'
body are unchanged.

Run (mote, through mote-run):
- go test ./internal/gateway -run 'Prompt|Context|Conversation|
  DeepSeek|Archive|Image|Lean|FileID': ok.
- go test ./internal/gui -run 'Context|Gateway|Sessions': ok.
- go vet: darwin gateway+gui, GOOS=linux -tags nogui, GOOS=windows.
- gofmt -l: clean.

TestFileIDConversationStillShows covers chat, responses and anthropic.
Each sends a 36 MiB turn of three 12 MiB pictures through the fake
DeepSeek, which names them by file id. It checks:
- the card draws all three, from memory and from the archive;
- the chat text is still there;
- the Sessions transcript holds the turn's text and three [image].

Broken by hand, each one red:
- wiring removed: memory, 0 pictures drawn;
- the archive's cap put back before the lean: archive not read;
- the conversation lean removed: the transcript keeps only the reply,
  cut:true (the reporter's "会话内容也看不到了");
- the ref not resolved: memory, 0 pictures drawn.

Not tried:
- the reporter's real DeepSeek account and the GUI by eye. No GUI file
  changed, so the GUI suite was not run.
- masking turned on explicitly with a lean body. The refs are plain
  text, so they are not expected to match a mask.
- Sessions read from an agent's own transcript (Claude Code, Codex)
  never pass through the gateway, so #5407 cannot touch them.

Reported-by: matrix0487
2026-11-06 13:42:40 +08:00