System-optimization: Why did a simple image + 'what do you see?' consume 14.3K in...

Documentation for Sessions

📝 System-optimization: Why did a simple image + 'what do you see?' consume 14.3K in...

Date: 2026-03-31
Time: 12:01:16 UTC
Session: gspace1-290.23
Agent: angular
Confidence: 95%
Status: ✅ Documented


📋 Decision Context

Question:

Why did a simple image + 'what do you see?' consume 14.3K input tokens in the VSCode extension Vitto chat?

Task: Reduce token consumption for image queries in VSCode extension


🎯 Decision Made

Chosen:

Truncated IDE context file content from full file to 60-line preview (~800 tokens). Selection capped at 4KB. Vitto has read_file tool for on-demand access.

Options Considered:

  1. Truncate file to first 60 lines + hint for read_file tool (chosen)
  2. Don't send file content at all — only path and language
  3. Send full content but use Anthropic prompt caching to amortize cost
  4. Implement two-tier prompting: lightweight for vision, full for code work

💭 Reasoning

Root cause: context-provider.service.ts line 31 called editor.document.getText() — sending the ENTIRE active file content with every message. A 300-line TS file = 3,000-5,000 tokens. Token breakdown: system prompt ~6K + full file content ~4K + conversation history ~2K + image ~1.3K + message ~10 = ~14.3K. The file content was the only component that's pure waste — Vitto has a read_file tool and can request content on-demand. Reducing to 60-line preview saves 2,000-5,000 tokens per message (40-50% reduction). Expected post-fix: ~7-9K tokens for same query. Selection text was also unbounded — capped at 4KB to prevent accidental token bombs from large selections.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation