Skip to content

[BUG] No limitation of image count in context window #8800

@jcjorel

Description

@jcjorel

Problem (one or two sentences)

While working with models that read images (ex: Claude 4.x) from MCP servers or file system, internal limitations of models regarding max image count in context window, are not taken in account.

For instance, Claude 4.x enforces a hard limit of 20 images maximum in the context window that generates this kind of errors:

API Request Failed
Unknown Error: The model returned the following errors: too many images and documents: 21 + 0 > 20

Ability to trim the oldest image(s) of the context window would be beneficial: could be either automatic (prefered) or through a specific compaction commmand.

This issue is limiting the ability of Roo Code to be used for significant browser based test campaigns especially.

Context (who is affected and when)

All Roo Code users that heavily rely on model image reading capability.

Reproduction steps

  1. Ask Roo to test an application with its browser_action tool,
  2. Ask for an extensive test that will take more than 20 browser viewport screenshots
  3. Observ the error

Expected result

When a new image must be added to a context window that reached its own image limit, the latest one must be trimmed with warning to the user.

Actual result

Fatal error forcing to stop the current session.

Variations tried (optional)

No way to circumvent the issue.

App Version

3.28.18

API Provider (optional)

AWS Bedrock

Model Used (optional)

Claude 4.x Sonnet models (but not specifc to)

Roo Code Task Links (optional)

No response

Relevant logs or errors (optional)

API Request Failed
Unknown Error: The model returned the following errors: too many images and documents: 21 + 0 > 20

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue/PR - TriageNew issue. Needs quick review to confirm validity and assign labels.bugSomething isn't working

    Type

    No type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions