Repository navigation
Conversation
🦋 Changeset detectedLatest commit: db5f4e7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db5f4e7416
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| this._register( | ||
| this.loopService.hooks.onDidFinishStep.register('full-compaction', async (ctx, next) => { | ||
| if (!ctx.signal.aborted) await this.afterStep(); | ||
| if (!ctx.signal.aborted) await this.afterStep(ctx.finishReason === 'tool_calls'); |
There was a problem hiding this comment.
Detect tool continuations from executed tools
When a low compaction trigger is configured and an OpenAI Responses model invokes a tool, ctx.finishReason is completed, not tool_calls: packages/core/src/llm/builtin/protocol/openai-responses/decode.ts maps a completed response to that value even when its output contains function calls, while ctx.tools records the executed calls. Consequently this branch does not defer soft compaction, so afterStep can compact the newly returned tool result before the continuation consumes it—the exact ordering this change is intended to prevent. Determine the continuation from the executed tools rather than the provider finish reason.
AGENTS.md reference: AGENTS.md:L192-L194
Useful? React with 👍 / 👎.
| if (this._compacting !== null || shouldBlock) { | ||
| await this.block(signal, turnId); |
There was a problem hiding this comment.
Keep soft compaction failures non-blocking
When compactionTriggerRatio is below the hard block ratio and the summary request fails—for example, the provider repeatedly returns an empty or truncated compaction response—this condition now enters block() solely because _compacting is non-null. The rejected compaction promise then propagates through onWillBeginStep, failing the whole user turn without attempting its normal model request, even though shouldBlock is false; previously this soft compaction ran in the background and its failure did not prevent the turn. Serialize the soft attempt without making its failure fatal unless the hard threshold was actually reached.
AGENTS.md reference: AGENTS.md:L192-L194
Useful? React with 👍 / 👎.
commit: |
Requirement or Bug
Resolve #2720.
当
compaction_trigger_ratio低于硬阻塞线时,auto compact 在后台运行,后续 agent step 继续写入 assistant/tool 历史,导致压缩提交前的快照校验反复失败。本 PR 让自定义低阈值压缩能够完成,同时保证工具 continuation 先消费原始工具结果。Bug Reproduction Steps
config.toml的[loop_control]中设置compaction_trigger_ratio = 0.6。Root Cause
软阈值触发压缩后,
beforeStep之前只在达到硬阻塞线时等待。压缩在途期间,下一步写入的 assistant/tool 历史改变了提交前快照,因此成功的压缩响应也会因historySafeToCompact校验失败而被丢弃,并在上下文未缩小的情况下反复重试。这是根本修复:在途 auto compact 与后续 step 串行执行,而不是禁止低阈值配置或绕过快照安全校验。
Code Changes
beforeStep在任何 auto compact 在途时等待,避免后续 step 与压缩提交并发写历史;硬阈值行为保持不变。afterStep对工具 continuation 只记录一次软压缩顺延。continuation 消费原始工具结果后,再按既有策略触发软压缩;新回合会清理该临时状态。@moonshot-ai/agent-core-v2的 patch changeset。Behavior Changes and Affected Users
compaction_trigger_ratio的 CLI、Desktop/Web、VS Code、ACP 与 SDK 会话受影响模块为
agent-core-v2的 full compaction 生命周期钩子。fullCompaction.test.ts分别覆盖上述三行行为,并保留 aborted step、硬阈值、telemetry 回合归属及 resume 一致性检查;没有修改公开 API、配置契约或持久化格式。无需更新用户文档,因为本次是恢复既有配置应有的行为。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.验证记录
fullCompaction.test.ts120/120 通过。tsc -p packages/agent-core-v2/tsconfig.json --noEmit通过。pnpm lint与check:duplication通过。