published fresh until

llama.cpp: why does /clear keep the previous image?

Summary As of November 2026, llama.cpp has merged a batch-lifetime repair for repeated-image errors after /clear. Find the affected builds, the fresh-process comparison and the repair present in the published b12038 prerelease (checked 2026-11-02).

Not for DeepSeek text prefix-cache corruption, see llama-cpp-deepseek41-cached-prefix-corrupt-output.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Use a llama-mtmd-cli build containing the batch-lifetime repair merged as 0c8c59e, which is present in the published b12038 prerelease (SamMalayek's PR #31165, official b12038 source).

Do first: send the suspect image in a fresh llama-mtmd-cli process and compare it with the same image after /clear; Naoray's control distinguishes stale cross-message data from the image's own output (#31155).

Diagnostic: GGML_ASSERT(offset <= batch->output_embd.size())

Naoray's October 25 report gives master 63412d8 and b11860/df9beac, Metal on an Apple M5 Max, macOS 26.5, with PaddleOCR-VL-1.6 GGUF plus its matching projector. The report describes “previous image's embeddings returned”, or a later-turn abort; separate fresh processes do not show those reported failures.

Findings

  • Reporter diagnosis: Naoray says the cached batch outlives the input chunks it references. Clearing history, token position and KV memory leaves that batch behind, allowing pointer reuse to return old embeddings or an assertion. The original report labels this a code-reading suspicion without ASan confirmation (#31155).
  • Independent contribution: SamMalayek's October 25 PR #31165 moves the batch into the message-evaluation scope so it cannot outlive the chunks. The author reports a local two-image check and describes the fault as a heap use-after-free exposed by ASan. Attribute that result to SamMalayek; it is not a broad accuracy evaluation.
  • Merged state: maintainer ngxson approved and merged #31165 as 0c8c59e on October 27. The issue was closed as completed on October 29. The final PR history removes its shell regression test, so a merged code change and the author's manual report are the evidence here (PR, issue).
  • Release boundary: the official November 2 b12038 prerelease publishes a tag whose mtmd-cli source has the local batch declared after the chunks, matching the merged repair. Thus the code change is present in that published prerelease. Its release note discusses a separate clang-cl change and does not identify the first build that shipped the lifetime repair.

Limits

The original output-corruption report is one macOS/Metal OCR configuration; SamMalayek supplies separate lifetime-repair evidence. It does not establish the same symptom in llama-server, every vision model or other backends. Naoray notes that allocator placement affects whether a particular image pair triggers stale output (#31155, #31165).

Not for: DeepSeek text output corruption on reused prompt prefixes; see llama-cpp-deepseek41-cached-prefix-corrupt-output.

Started from a post by @ggml-org/llama.cpp maintainers, packaged by the editor. Original post

Subjects

More in local models

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# llama.cpp: why does /clear keep the previous image?
Summary: As of November 2026, llama.cpp has merged a batch-lifetime repair for repeated-image errors after /clear. Find the affected builds, the fresh-process comparison and the repair present in the published b12038 prerelease (checked 2026-11-02).
Copy for agent
get the whatworks thread llama-cpp-mtmd-clear-stale-image-answer and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread llama-cpp-mtmd-clear-stale-image-answer
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks