farion1231 / farion1231/cc-switch

Claude Desktop在使用kimi code作为提供商,且单对话长时间运行时(期间使用子代理),会高概率瞬时消耗大量额度

Open
#6,830 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
133k
Forks
9.2k
Avg merge
3d 19h
Merged PRs (30d)
51

Description

### Self Checks / 自检

- [x] I have read the [FAQ](https://github.com/farion1231/cc-switch#faq) section in README.
我已阅读 README 中的[常见问题](https://github.com/farion1231/cc-switch#常见问题)。

- [x] I have searched for [existing issues](https://github.com/farion1231/cc-switch/issues), including closed ones.
我已搜索过[已有的 Issue](https://github.com/farion1231/cc-switch/issues),包括已关闭的。

### CC Switch Version / 版本号

3.20.0

### Operating System / 操作系统

Windows

### Related App / 涉及应用

Claude Code, Other / 其他

### Steps to Reproduce / 重现步骤

当在一个对话中长时间运行(长上下文),同时有主对话或一个、多个子代理交替运行时,会高概率出现一次极高的输入,这个输入的token数与当时所使用的上下文窗口的token数比较近似,目前没有发现固定的触发条件
本次对话中,主模型为sonnet(k3 1m),子代理使用Fable(k3-265k)
对应的cc Switch截图
Image
对应的kimi code记录
Image

在主对话中给agent的规则
本次实现时,不要出现多个代理并行的情况,可以使用子代理进行审阅或实现,注意尽可能不要同时运行超过一个对话进程(包括主对话,可以出现主对话监控一个子代理同时运行的情况但不建议长时间出现这个情况),尽可能不要创建过多的子代理,要尽可能对已创建的子代理进行复用避免浪费上下文(但当前Claude子代理的上下文好像不会自行压缩,会出现上下文失控),建议使用的模型sonnet 1m(仅在主对话使用),Fable(子代理,但其上下文长度仅有200k),以上为本次实现中子代理以及成本控制相关的要求

以下为对应的模型映射以及相关的供应商设置
Image

Image

以下为最近一次发生时的大约前后3分钟的日志记录

[log.txt](https://github.com/user-attachments/files/31452699/log.txt)

### Expected Behavior / 期望行为

在已配置"成本控制、子代理复用、避免并行"等规则的前提下,系统应确保:
1.任何单次交互的输入量与当前操作的实际信息需求相匹配,不应无预警地一次性加载主对话的完整上下文历史;
2.若某个操作确实需要引用大量历史上下文,系统应优先采用摘要、截断或增量方式,而非全量传递;

### Actual Behavior / 实际行为

_No response_

### Additional Context / 补充信息

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the attached log.txt and reproducing a long-running conversation with subagents using the reported provider and model mapping. Compare the recorded token usage with the expected bounded, summarized, or incremental context behavior; done means identifying a reproducible trigger and verifying that unexplained full-context spikes no longer occur.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.