Skip to content

[BUG] /auth OpenAI mode , no adaptable 'sessionTokenLimit' and cli display ( XX % context left) #1101

@gigascake

Description

@gigascake

What happened?

When using the /auth OpenAI mode, the session token limit in the ~/.qwen/settings.json file is not applied, and only the 132K context window is applied. I was testing a qwen3-coder model with a 745472 context window, and found that this was not applied.

Image

What did you expect to happen?

this Message : IMPORTANT: This conversation approached the input token limit for qwen3_coder. A compressed context will be sent for future message 700000 to 650000 tokens. (left 5% to 15%)

i saw 130000 to 100000, (left 1% to 30%)

✦ Based on my investigation of the Qwen Code CLI UI implementation, I can now answer your question about whether the 'context left' display properly applies 
  the sessionTokenLimit configuration.

  Analysis of Context Left Display Implementation

  The CLI UI's 'context left' display in the footer does NOT directly use the sessionTokenLimit configuration value. Instead, it calculates remaining 
  context based on the model's inherent token limits.

  Here's how it actually works:

   1. ContextUsageDisplay Component (packages/cli/src/ui/components/ContextUsageDisplay.tsx):
      - Takes promptTokenCount and model as props
      - Calculates percentage using tokenLimit(model) function
      - Shows remaining tokens as a percentage of the model's maximum context window

   2. Token Limit Calculation (packages/core/src/core/tokenLimits.ts):
      - Uses model-specific hard-coded limits (e.g., 128K for Qwen3-Coder models)
      - Does not reference sessionTokenLimit configuration
      - The calculation is: promptTokenCount / tokenLimit(model)

   3. Session Token Limit Configuration (sessionTokenLimit in ~/.qwen/settings.json):
      - Is used in the core LLM client layer for enforcing actual API call limits
      - Is NOT used in UI display calculations
      - Applied in packages/core/src/core/client.ts during API call processing

  Conclusion

  The CLI UI's 'context left' display does NOT apply the sessionTokenLimit configuration value. It only shows remaining tokens based on the model's 
  inherent token limits, not the user-defined session limit. This is a discrepancy in the UI implementation.

  The sessionTokenLimit configuration is intended to limit the total tokens used in a session but isn't reflected in the UI's display of remaining 
  context. The UI only shows the model's maximum context window percentage, regardless of the user's configured session limit.

  This means that even if a user sets sessionTokenLimit to a lower value in their settings, the UI will still show the full model's token allowance 
  percentage-wise, potentially misleading the user about their actual session token usage.

  The UI should ideally incorporate the sessionTokenLimit when calculating the displayed remaining context percentage, but currently it doesn't do so.

Client information

Client Information

Run qwen to enter the interactive CLI, then run the /about command.

$ qwen /about

╭───────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                           │
│ About Qwen Code                                                                           │
│                                                                                           │
│ CLI Version                    0.3.0-preview.0                                            │
│ Model                          qwen3_coder                                                │
│ Sandbox                        no sandbox                                                 │
│ OS Platform                    linux                                                      │
│ OS Arch                        x64                                                        │
│ OS Release                     6.12.1-300.vanilla.fc40.x86_64                             │
│ Node.js Version                v22.21.1                                                   │
│ NPM Version                    10.9.4                                                     │
│ Session ID                     714ec849-f4ed-4a70-b6f9-3cd429ee35b2                       │
│ Auth Method                    openai                                                     │
│ Base URL                       http://192.168.50.88:8000/v1                               │
│ Memory Usage                   313.1 MB                                                   │
│                                                                                           │

Login information

No response

Anything else we need to know?

No response

Metadata

Metadata

Assignees

Labels

type/supportUser support and help requests

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions