9ebe435ca1
Port from google-gemini/gemini-cli#24440. Browser snapshots (accessibility trees from browser_snapshot) are the largest single tool outputs — each one can be 8,000+ characters. Only the most recent snapshot reflects the current page state; older ones waste context-window tokens. New pre-pass runs before every API call (zero LLM cost): - Scans messages for browser_snapshot and browser_vision tool results - Replaces all but the most recent with a compact placeholder - Skips short outputs (<200 chars, likely error messages) - Idempotent — already-superseded snapshots are not re-processed This complements the existing generic tool output pruning in ContextCompressor._prune_old_tool_results(), which only triggers during full compression. The new function runs proactively every turn, specifically targeting the highest-token-cost tool outputs. Includes 11 tests covering all edge cases.