feat(vision): cache vision-proxy image descriptions - #120
Conversation
Cache the text description produced by the vision proxy per image (sha-256 of its base64 bytes) so already-described images are reused on later turns without calling the vision model again - saving Copilot quota and latency. Only the message containing a new image is sent to the vision model. The cache is capped at 200 entries with FIFO eviction. Also sync package-lock.json version to 0.5.1.
|
Nice one @ChauThan this is a clean fix. the cache mirrors the reasoning-content cache nicely, and the 7 tests cover the important cases (the partial-hit one especially). a couple of things i want to double check before merging:
also, the lockfile sync to 0.5.1 fixes a mismatch that was sitting on main (package.json was already 0.5.1 but the lockfile was still 0.5.0), so that's a welcome side effect. the extra i'll run compile + the full test suite locally before merging. thanks for the PR. |
|
@ltmoerdani
I'll do it if you agree. |
|
@ChauThan thanks for the follow-up.
|
|
@ltmoerdani done - added the setting flag as discussed.
Ready for review + test whenever. Thanks! |
|
@ChauThan nice one, this rounds it out well. i pulled the branch and ran the checks locally: compile passes, 168 tests pass (0 fail), lint:js and markdown lint on the feature doc are clean. the setting registration, README table, and the feature doc section all line up. merging now, thanks! |
Bump version 0.5.1 -> 0.5.2 and finalize CHANGELOG [Unreleased] -> [0.5.2]. Shipped in 0.5.2: - PR #123 (merged fec411b): DeepSeek V4 multi-turn reasoning_content echo fix - PR #124 (merged): BYOK group flow fix (#121) - PR #125 (merged 3001d68): Agents window BYOK bridge + provider remove (#122) - PR #120 (merged): Vision proxy description cache + whole-conversation mode - PR #126 (merged 7be0c06): typeof guard + reasoning-history unit tests (follow-up on #123) Docs sync: - New issue docs: 55 (PR #123), 56 (PR #120), 57 (PR #124), 58 (PR #125), 59 (PR #126), 60 (release 0.5.2 plan) - Architecture timeline: +3 entries (#123, #126, reasoning module note) - Devlog: PR #126 merge entry, release phase update - Features: agents-window #122 update, vision-proxy #120 enhancement note - Corrected #55 false claim that #126 was already merged
Summary
Caches the text description produced by the vision proxy per image (SHA-256 of its base64 bytes), so images that were already described in earlier turns are reused without calling the vision model again. This saves Copilot quota and latency in multi-turn conversations where text-only models receive the same image attachments on every turn.
What changed
src/visionProxyCache.ts- an in-memory cache keyed by image content hash, capped at 200 entries with FIFO eviction (mirroring the reasoning-content cache).src/extension.ts-proxyVision()now:selectChatModels()/sendRequest()are skipped lazily.apiMessagewhen one input message expands into several (e.g. tool results).src/test/visionProxy.test.ts- unit tests for the cache (stable keys, lookup/store, partial hits, reuse, FIFO eviction, clear).package-lock.json- version synced to0.5.1.Why
Without a cache,
proxyVision()calls the vision model viamodel.sendRequest()on every turn to describe the same bytes again - wasting Copilot quota, adding latency, and returning a different description each time.Validation
npm run compilepassesnpm testpasses - 168 tests (7 new for the cache)npm run lint:jspassesIssue
Closes #119