Skip to content

fix(agent-core): use max output size for compaction budget - #1129

Merged
wbxl2000 merged 4 commits into
MoonshotAI:mainfrom
qkunio:fix/compaction-max-output-size-local
Jun 27, 2026
Merged

fix(agent-core): use max output size for compaction budget#1129
wbxl2000 merged 4 commits into
MoonshotAI:mainfrom
qkunio:fix/compaction-max-output-size-local

Conversation

@qkunio

@qkunio qkunio commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

三周前v0.8.0的bug了,现在v0.20.0了,PR还没通过,也没人修,真的希望能解决一下

Related Issue

Resolve #476

Problem

这个版本在v0.8.0的时候就有了,我那时候提了个PR 点击查看,这个只需要1行代码就能解决,但是没人审核,没想到现在还没人通过。

这个问题也很简单的,就是对于OpenAI格式的第三方模型,运行/compact 的时候,只暴露了兜底值reservedContextSize,没有传入模型配置里的 maxOutputSize。只需要传入就好了,我还补了一些测试用例和changeset。感觉是之前写的时候漏掉了这个路径。

What changed

packages/agent-core/src/agent/compaction/full.ts 里添加了一行代码:

maxOutputSize: this.agent.config.maxOutputSize

让上下文压缩的时候,传入的maxOutputSize与普通对话路径 (packages/agent-core/src/agent/index.ts) 保持一致。

同时新增测试用例,验证 compaction 从模型配置读取maxOutputSize作为 hard cap。

before:
截屏2026-06-26 16 57 41

after:
截屏2026-06-26 16 56 50

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 22844a0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jun 26, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@22844a0
npx https://pkg.pr.new/@moonshot-ai/kimi-code@22844a0

commit: 22844a0

@wbxl2000
wbxl2000 merged commit d02b5c4 into MoonshotAI:main Jun 27, 2026
9 checks passed
@wbxl2000

Copy link
Copy Markdown
Collaborator

👍 Thanks for the PR — this will be included in the next release.

@github-actions github-actions Bot mentioned this pull request Jun 27, 2026
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Jul 11, 2026
…I#1129)

* fix(agent-core): use max output size for compaction budget

* chore: add changeset for compaction max output size fix

* docs: rephrase compaction changeset

---------

Co-authored-by: qkunio <qkunio@163.com>
Co-authored-by: qer <wbxl2000@outlook.com>
(cherry picked from commit d02b5c4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compaction Fails with APIContextOverflow due to sending the wrong context length

2 participants