Skip to content

fix: replay empty thinking verbatim on preserved-thinking endpoints - #1773

Merged
RealKai42 merged 1 commit into
mainfrom
fix/thinking-replay-verbatim
Jul 16, 2026
Merged

fix: replay empty thinking verbatim on preserved-thinking endpoints#1773
RealKai42 merged 1 commit into
mainfrom
fix/thinking-replay-verbatim

Conversation

@RealKai42

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue. This removes an obsolete wire-level fallback introduced earlier for Anthropic-compatible and Kimi preserved-thinking endpoints.

Problem

When assistant history is replayed to Anthropic-compatible or Kimi endpoints with thinking keep = "all", the client substituted a single space for missing or empty thinking content: it prepended a placeholder thinking block to assistant messages that had none, replaced the last unsigned thinking block when every thinking block was empty, and sent a space as reasoning_content on the Kimi protocol. That fallback guarded against strict endpoints that rejected assistant messages with missing or empty thinking. Those endpoints no longer reject such payloads, so the placeholder now only distorts the replayed history.

What changed

  • Removed the preserved-thinking backfill from the Anthropic message conversion in both engines: assistant messages without thinking content keep their original shape, and an all-empty thinking sequence is replayed verbatim. Signed thinking blocks were, and remain, untouched.
  • Removed the matching Kimi fallback so reasoning_content carries the original empty value instead of a space.
  • Updated provider, round-trip, context-management, and e2e tests to assert verbatim replay; cases that were already verbatim (disabled thinking, non-all keep values, signed blocks, non-assistant messages) remain as regression coverage.

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.

Remove the wire-level fallback that substituted a space for empty
thinking content when replaying assistant history to Anthropic-compatible
and Kimi endpoints with thinking keep=all. The strict endpoints that
motivated the placeholder no longer reject empty thinking, so the
placeholder only distorted replayed history.
@changeset-bot

changeset-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8917781

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 Jul 16, 2026

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

commit: 8917781

@RealKai42
RealKai42 merged commit 1169a6d into main Jul 16, 2026
15 checks passed
@RealKai42
RealKai42 deleted the fix/thinking-replay-verbatim branch July 16, 2026 09:00
This was referenced Jul 16, 2026
ywh114 pushed a commit to ywh114/kimi-code that referenced this pull request Jul 19, 2026
…oonshotAI#1773)

Remove the wire-level fallback that substituted a space for empty
thinking content when replaying assistant history to Anthropic-compatible
and Kimi endpoints with thinking keep=all. The strict endpoints that
motivated the placeholder no longer reject empty thinking, so the
placeholder only distorted replayed history.
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.

1 participant