Skip to content

fix(agent-core): prepend repeat reminders so they survive oversized-result truncation#2176

Draft
vincentllm wants to merge 2 commits into
MoonshotAI:mainfrom
vincentllm:dedupe-reminder-truncation
Draft

fix(agent-core): prepend repeat reminders so they survive oversized-result truncation#2176
vincentllm wants to merge 2 commits into
MoonshotAI:mainfrom
vincentllm:dedupe-reminder-truncation

Conversation

@vincentllm

@vincentllm vincentllm commented Jul 25, 2026

Copy link
Copy Markdown

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) and agent/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.
  • Regression tests added to the existing test files of both engines: an oversized (60K-char) result at streak 3 must contain the reminder within its first 2,000 chars (the preview window), plus prepend-placement assertions. Three existing ContentPart[] assertions that assumed tail placement were updated.
  • Changeset: @moonshot-ai/kimi-code patch.

Note: I could not run pnpm test locally (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

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my fix works (written per existing patterns; not executed locally — see note above).
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

…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-bot

changeset-bot Bot commented Jul 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1b3c785

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

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.

Dedupe repeat reminders never reach the model for oversized tool results (>50K chars)

1 participant