Skip to content

Input token count too large to rescue session #16780

Description

@jfietz

What happened?

API call from gemini-cli fails with

✕ [API Error: [{                                                                                                                        
    "error": {                                                                                                                          
      "code": 400,                                                                                                                      
      "message": "Request contains an invalid argument.",                                                                               
      "errors": [                                                                                                                       
        {                                                                                                                               
          "message": "Request contains an invalid argument.",                                                                           
          "domain": "global",                                                                                                           
          "reason": "badRequest"                                                                                                        
        }                                                                                                                               
      ],                                                                                                                                
      "status": "INVALID_ARGUMENT"                                                                                                      
    }                                                                                                                                   
  }                                                                                                                                     
  ]]                                                                                                                                    

Trying to recover with /compress or any other command also fails with too large of a context.

My setting should be pretty standard. I did allow execution of compile and test steps, so the last iteration ran for a long time.

Running compress, I get some actual information about the context size:

✕ [API Error: [{                                                                                                                        
    "error": {                                                                                                                          
      "code": 400,                                                                                                                      
      "message": "Request contains an invalid argument.",                                                                               
      "errors": [                                                                                                                       
        {                                                                                                                               
          "message": "Request contains an invalid argument.",                                                                           
          "domain": "global",                                                                                                           
          "reason": "badRequest"                                                                                                        
        }                                                                                                                               
      ],                                                                                                                                
      "status": "INVALID_ARGUMENT"                                                                                                      
    }                                                                                                                                   
  }                                                                                                                                     
  ]]                                                                                                                                    
                                                                                                                                        
✕ [API Error: Failed to generate content: The input token count (2056684) exceeds the maximum number of tokens allowed (1048576).]      
                                                                                                                                        
✕ Failed to compress chat history: Failed to generate content: The input token count (2056684) exceeds the maximum number of tokens     
  allowed (1048576).                                                                                                                    
                                                                                                                                        
✕ Failed to compress chat history: Failed to generate content: Request contains an invalid argument.  

What did you expect to happen?

Compress to succeed or at least to have a documented way returned for how to rescue the session and its context.

Client information

  • CLI Version: 0.23.0
  • Git Commit: N/A
  • Session ID: 37baba72-22ba-478e-85ed-00e88ddd5139
  • Operating System: linux v22.21.1
  • Sandbox Environment: no sandbox
  • Model Version: auto-gemini-3
  • Memory Usage: 270.3 MB
  • Terminal Name: kitty(0.45.0)
  • Terminal Background: #1e1e2e
  • Kitty Keyboard Protocol: Supported

Login information

Google Account

Anything else we need to know?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/platformIssues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions