Skip to content

Replace images with placeholders in summarization prompt#309643

Merged
bhavyaus merged 1 commit intomainfrom
dev/bhavyau/fix-summarization-too-many-images
Apr 14, 2026
Merged

Replace images with placeholders in summarization prompt#309643
bhavyaus merged 1 commit intomainfrom
dev/bhavyau/fix-summarization-too-many-images

Conversation

@bhavyaus
Copy link
Copy Markdown
Collaborator

@bhavyaus bhavyaus commented Apr 13, 2026

Problem

Gemini models hit "Too many images in request: 11 images provided, but the model supports a maximum of 10 images" during foreground, background, and inline summarization (~29 events in 3 days across gemini-3.1-pro-preview and gemini-3-flash-preview).

Root Cause

The summarization prompt renders the full conversation history including all image content parts (user-attached images and tool-result screenshots). When a conversation accumulates >10 images, Gemini rejects the request.

Fix

Replaces Image content parts with a [Image was attached] text placeholder.

Copilot AI review requested due to automatic review settings April 13, 2026 22:04
@bhavyaus bhavyaus enabled auto-merge (squash) April 13, 2026 22:05
@bhavyaus bhavyaus added this to the 1.116.0 milestone Apr 13, 2026
@bhavyaus bhavyaus added the ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch label Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

Screenshot Changes

Base: 1ddb07e7 Current: 19706445

Changed (1)

chat/aiCustomizations/aiCustomizationManagementEditor/McpBrowseMode/Light
Before After
before after

@vs-code-engineering
Copy link
Copy Markdown
Contributor

This PR will be automatically cherry-picked to release/1.116 when merged.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents Gemini summarization requests from failing when a conversation contains >10 images by replacing image content parts with a text placeholder in the summarization prompt (post-render), while keeping the main agent prompt unchanged.

Changes:

  • Run an additional post-processing step on the rendered ChatMessage[] to replace Image content parts with a text placeholder.
  • Add replaceImageContentWithPlaceholders() helper and invoke it after stripCacheBreakpoints().
Show a summary per file
File Description
extensions/copilot/src/extension/prompts/node/agent/summarizedConversationHistory.tsx Replaces image content parts with a text placeholder before sending summarization requests to avoid Gemini “too many images” errors.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

@bhavyaus bhavyaus force-pushed the dev/bhavyau/fix-summarization-too-many-images branch from dd66774 to f136c89 Compare April 13, 2026 22:23
Gemini models enforce a strict image count limit (max 10) that is
exceeded when conversation history contains many tool-result screenshots
or user-attached images. The summarization model only needs text to
produce a summary.

Replace image content parts with '[Image was attached]' text placeholders
instead of passing them through. This avoids the 'Too many images in
request' error while preserving the signal that an image was present
(so the summary can reference it accurately).
@bhavyaus bhavyaus force-pushed the dev/bhavyau/fix-summarization-too-many-images branch from f136c89 to 553b595 Compare April 14, 2026 05:15
@bhavyaus bhavyaus merged commit 182bcf4 into main Apr 14, 2026
26 checks passed
@bhavyaus bhavyaus deleted the dev/bhavyau/fix-summarization-too-many-images branch April 14, 2026 05:38
@vs-code-engineering vs-code-engineering bot added release-cherry-pick Automated cherry-pick between release and main branches and removed ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch labels Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-cherry-pick Automated cherry-pick between release and main branches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants