Skip to content

Comments

Fix message too large issue.#19499

Merged
gundermanc merged 2 commits intomainfrom
gundermanc/too-long
Feb 19, 2026
Merged

Fix message too large issue.#19499
gundermanc merged 2 commits intomainfrom
gundermanc/too-long

Conversation

@gundermanc
Copy link
Member

@gundermanc gundermanc commented Feb 19, 2026

Summary

Fixes an issue where users can see an error message indicating that a message is too long to send.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @gundermanc, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where users might encounter 'message too large' errors by enhancing the chat compression service. The core improvement lies in its strategy for handling chat history when previous compression attempts have failed. Instead of completely bypassing compression, the service now intelligently applies truncation to reduce message size, thereby preventing repeated failures and optimizing resource usage, ultimately leading to a more robust messaging experience.

Highlights

  • Refined Chat Compression Logic: The chat compression service now handles previously failed compression attempts more gracefully. Instead of entirely skipping compression, it will proceed but will only rely on truncation to reduce message size, avoiding repeated LLM calls for summarization if a previous attempt failed and is not forced.
  • Improved Message Size Handling: This change aims to mitigate 'message too large' errors by ensuring that some form of compression (at least truncation) is always attempted, even after a prior summarization failure, without incurring unnecessary LLM costs.
  • Updated Test Case: A test case in chatCompressionService.test.ts was updated to reflect the new behavior, specifically changing a force parameter from true to false to test the scenario where compression is attempted after a failure but not forced.
Changelog
  • packages/core/src/services/chatCompressionService.test.ts
    • Updated a test case to reflect the refined compression logic, specifically changing the force parameter from true to false in a compress call.
  • packages/core/src/services/chatCompressionService.ts
    • Removed the condition that previously prevented any compression attempt if hasFailedCompressionAttempt was true and force was false.
    • Introduced new logic to specifically handle cases where summarization previously failed and is not forced, by performing only truncation-based compression to reduce token count without invoking the LLM again.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to fix an issue where a message can be too large to send by improving the chat history compression logic. The change correctly removes the logic that prevented re-attempting compression after a failure. However, the new fallback logic for failed summarizations is incomplete and could lead to an unrecoverable state if the history is too large due to many small messages rather than large tool outputs. I've provided a critical suggestion to implement a more robust hard truncation fallback, ensuring the context size can always be managed and preventing the tool from getting stuck, aligning with the rule on preventing infinite loops in recursive handlers.

@github-actions
Copy link

github-actions bot commented Feb 19, 2026

Size Change: +1.18 kB (0%)

Total Size: 24.5 MB

Filename Size Change
./bundle/gemini.js 24.5 MB +1.18 kB (0%)
ℹ️ View Unchanged
Filename Size
./bundle/sandbox-macos-permissive-open.sb 890 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB
./bundle/sandbox-macos-strict-open.sb 4.82 kB
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB

compressed-size-action

@gundermanc gundermanc marked this pull request as ready for review February 19, 2026 17:11
@gundermanc gundermanc requested a review from a team as a code owner February 19, 2026 17:11
@@ -285,6 +282,35 @@ export class ChatCompressionService {
config,
);

// If summarization previously failed (and not forced), we only rely on truncation.
// We do NOT attempt to invoke the LLM for summarization again to avoid repeated failures/costs.
if (hasFailedCompressionAttempt && !force) {
Copy link
Contributor

Choose a reason for hiding this comment

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

consider factoring this out into a helper

@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Feb 19, 2026
@gundermanc gundermanc added this pull request to the merge queue Feb 19, 2026
Merged via the queue into main with commit c276d0c Feb 19, 2026
49 of 51 checks passed
@gundermanc gundermanc deleted the gundermanc/too-long branch February 19, 2026 19:24
spencer426 pushed a commit that referenced this pull request Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants