Skip to content

Statusline context (cxt) percentage is inaccurate #4025

@kaisersong

Description

@kaisersong

问题

Statusline 中显示的 cxt(上下文使用百分比)不准确,无法可靠地用来判断何时需要执行 /compact

期望行为

cxt 应准确反映当前上下文窗口的真实占用率——即当前对话发送给模型的完整 token 数(system prompt + 消息历史 + tool definitions + tool results)占模型上下文窗口的百分比。

当前行为

显示的百分比与实际上下文占用不符(偏低或偏高),用户无法据此决定何时 compact,导致:

  • 上下文实际已接近满载但显示仍很低,突然报错
  • 或者反过来,过早 compact 丢失有用上下文

建议

  1. 使用 API 返回的 input_tokens(最近一次响应中的值)作为分子——它已经包含了发送给模型的完整上下文
  2. 提供配置项让用户选择计算方式(如 settings.json 中的 contextDisplay: "input_only" | "input+output"
  3. 或至少在文档中说明 cxt 具体代表什么,以便用户正确解读

环境

  • OS: macOS (arm64)
  • Shell: zsh
  • Qoder CLI with custom statusline

Metadata

Metadata

Assignees

Labels

Type

No type
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