Skip to content

Title: [Bug] AI commit message fails with 429 rate_limit_exceeded on small changes after a large change fails in another project #2893

Open

Description

@wintry

Description:
When using the AI commit message generation feature, if it fails on a massive commit in one project, the failure seems to "poison" the context cache globally. After the initial failure, generating a commit message for a very small change in a completely different project also fails with the exact same 429 (tokens: rate_limit_exceeded) error.

Based on the token count in the error message (e.g., requested 1344+ tokens for a tiny frontend change), the client or backend is clearly caching and sending the massive diff from the previous failed attempt across different projects, rather than clearing the context and strictly sending only the currently staged files.

Steps to Reproduce:

In Project A, make a massive code modification (e.g., huge backend Java file updates).

Stage the changes and click to generate an AI commit message. It fails (likely due to the diff being too large).

Switch to Project B (a completely different project).

Make a very small modification (e.g., a few lines of front-end Vue code) and stage only this small file.

Click to generate the AI commit message in Project B.

Observe the error: HTTP 429 (tokens: rate_limit_exceeded) Request too large for model...

Expected Behavior:
The AI commit message prompt should be strictly stateless and isolated per request. It should clear any previous conversational context, cache, or failed diffs—especially across different projects—to prevent token limit exhaustion. The prompt should only contain the git diff --cached for the current project.

Actual Behavior:
The prompt caches or mixes in the massive diff from the previously failed attempt in Project A, causing the tiny request in Project B to exceed the model's token limits.

Environment:

OS: [Windows 11]

Git Client Version: [v2026.24]

AI Model Used: qwen/qwen3.8-27b (via OpenRouter/API)

跨项目生成提交信息报 429 rate_limit_exceeded 错误(大改动失败后导致小改动也失败)

问题描述:
在使用 AI 生成提交信息功能时,似乎存在严重的全局上下文(Context)缓存泄漏问题。当我在一个项目中尝试为巨大的改动生成提交信息并失败后,切换到另一个完全不同的项目,为极小的改动生成提交信息时,依然会报出相同的 429 (tokens: rate_limit_exceeded) 错误。

从报错信息中的 Token 数量(例如为极小的前端改动请求了 1344+ Tokens)可以明显看出,客户端或后端并没有清空上一次失败请求的缓存,而是把上一个项目中那个巨大的 Diff 一并塞进了当前的 Prompt 里。

复现步骤:

在 项目 A 中,进行一次巨大的代码修改(例如后端 Java 文件的巨大改动)。

暂存这些改动并点击“AI 生成提交信息”,触发生成失败(可能是因为 Diff 太大)。

切换到 项目 B(一个完全不同的项目)。

对某个文件进行极小的修改(例如几行前端代码),并仅仅暂存这一个小文件。

在项目 B 中点击“AI 生成提交信息”按钮。

触发报错:HTTP 429 (tokens: rate_limit_exceeded) Request too large for model...

期望表现:
每次点击 AI 生成提交信息时,请求应该是完全无状态且相互隔离的。客户端必须清空所有历史对话上下文、缓存或上一次失败的 Diff(尤其是跨项目切换时),确保 Prompt 仅仅包含当前项目当前已暂存的 git diff --cached 内容。

实际表现:
系统缓存并携带了上一次在项目 A 中失败的巨大 Diff,导致项目 B 中极小的请求体积膨胀,超出了大模型的 Token 限制。

运行环境:

操作系统: [ Windows 11]

客户端版本: [v2026.24]

使用的模型: qwen/qwen3.8-27b

Activity

  1. love-linger commented on Nov 18, 2026

    @love-linger
    Collaborator

    实际上每次执行生成命令,SourceGit 都创建一个新的 OpenAIClient。目前并不清楚为什么你那里会有缓存。

  2. self-assigned this
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

need-more-infoExtra information or replay is needed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions