fix(agent-core): prepend repeat reminders so they survive oversized-result truncation#2176
Draft
vincentllm wants to merge 2 commits into
Draft
fix(agent-core): prepend repeat reminders so they survive oversized-result truncation#2176vincentllm wants to merge 2 commits into
vincentllm wants to merge 2 commits into
Conversation
…esult truncation The dedupe repeat reminders (streak 3/5/8) were appended at the tail of the tool output, but the oversized-result offload path keeps only a 2K head preview, so the reminder was silently cut off exactly in the large-output scenarios where repeat loops are most likely. Prepend the reminder ahead of the output in both engines (agent-core, agent-core-v2) and add regression tests covering the truncation window.
🦋 Changeset detectedLatest commit: 1b3c785 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 |
…ation in regression tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
Resolve #2177
Problem
See linked issue. In short: the dedupe repeat reminders (streak 3/5/8) are appended at the tail of the tool output, and the oversized-result offload path keeps only a 2K head preview — so the reminders are silently discarded for any tool result >50K chars, in both v1 (
agent-core) and v2 (agent-core-v2). The turn's only remaining guardrail is the streak-12 force stop.What changed
agent/turn/tool-dedup.ts(v1) andagent/toolDedupe/toolDedupeService.ts(v2): the reminder is now prepended ahead of the result output instead of appended at the tail, so it survives the head-only truncation preview. A comment documents the ordering constraint.ContentPart[]assertions that assumed tail placement were updated.@moonshot-ai/kimi-codepatch.Note: I could not run
pnpm testlocally (no pnpm available in this environment); the new and updated tests follow the existing harness patterns and should be exercised in CI. Happy to iterate if maintainers prefer an alternative fix (e.g. budgeting before dedupe finalize, or a head+tail preview).Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.