-
Notifications
You must be signed in to change notification settings - Fork 405
Cache local image summaries #244
Copy link
Copy link
Closed
Labels
P2Normal priority bug or improvement with limited blast radius.Normal priority bug or improvement with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Metadata
Metadata
Assignees
Labels
P2Normal priority bug or improvement with limited blast radius.Normal priority bug or improvement with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Problem
Repeated local image summary runs do not appear to use the summary cache. The same local image, prompt options, and model path can invoke the model again instead of returning a cached summary.
This is separate from #240 / #241. That issue/PR is about transcript cache keying for local audio/video extraction. This one is about summary caching for binary image attachments.
Repro
Use any local JPG/PNG and a CLI model path that makes repeated calls observable:
Expected:
Actual:
Likely cause
The asset summary path gates summary cache reads/writes on both
contentHashandpromptHash:src/run/flows/asset/summary.tscomputescontentHash = buildPromptContentHash({ prompt: promptText }).summarycache whencacheStore && contentHash && promptHash.summarycache under the same condition.For image attachments,
prepareAssetPrompt()builds a normal file summary prompt and attaches the image bytes separately. The prompt's<content>block is empty because the content is binary, not inline text. That makesbuildPromptContentHash()returnnull, so the summary cache block is skipped entirely.Relevant code paths:
src/run/flows/asset/preprocess.ts, image attachments are passed as binaryattachments.packages/core/src/prompts/file.ts,buildFileSummaryPrompt()usescontent: "".src/cache-keys.ts,buildPromptContentHash()returnsnullfor empty content.src/run/flows/asset/summary.ts, summary cache lookup/write requirecontentHash.Suggested direction
For binary attachments, the summary cache needs a stable content identity that is not derived from inline prompt content. For local images, that could include a hash of the image bytes, or a file identity that includes the local file URL/path plus size/mtime. Byte hashing is likely more robust across path changes, while file metadata is cheaper but can miss same-content moves/copies.
The cache key should still include the existing prompt hash, model, length, language, and cache format version so prompt/options/model changes invalidate correctly.