fix: make blind-mode describe prompt unique per image #15
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/alt-text-provider-cache-bust"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
During the July 6 timer session, every blind-mode alt text after the first generation described the first image, even though the generated images on disk were all correct and distinct. The assistant concluded
generate_imagewas broken (it wasn't) and persisted that false conclusion into its knowledge files.Investigation showed the whole client pipeline was correct: the sha256 hashes logged by
ImageDescriptionServicematch the files on disk exactly, so the correct bytes were sent on every request. The stored alt texts for images 2–7, however, all describe image 1 — each with fresh wording, meaning the vision model genuinely attended to image 1's pixels on every call.Root cause
An upstream provider bug: DeepInfra (serving
moonshotai/kimi-k2.7-codevia OpenRouter) keys its prompt cache on the text prefix only. Since every describe call used the identical text"Describe this image in detail.", subsequent requests hit the cache including the previous request's image tokens (cached_tokenscovered the full prompt) and returned a description of the wrong image. Reproduced and confirmed by pinning providers: Novita, Inceptron, and SiliconFlow behave correctly; DeepInfra reliably serves the stale image.Fix
Embed the image's sha256 (already computed for the alt-text cache key) in the prompt text, so no two describe requests share a text prefix. Verified against the affected provider: with the nonce,
cached_tokensdrops to the shared system-prompt prefix only and the correct description is returned.The nonce is not part of the cached alt text, so existing cache rows stay valid. Note: the wrong descriptions persisted in
image_alt_textsduring the affected session (hashesa02348…,4b1bf9…,f76ba0…,bd838b…,908ee2…,b3fe2e…) still need a one-off cleanup on the server — this PR only prevents new poisoning.🤖 Generated with Claude Code