Skip to content

fix: drop empty text blocks during projection - #910

Merged
kermanx merged 2 commits into
mainfrom
xtr/drop-empty-text-projection
Jun 19, 2026
Merged

fix: drop empty text blocks during projection#910
kermanx merged 2 commits into
mainfrom
xtr/drop-empty-text-projection

Conversation

@kermanx

@kermanx kermanx commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue; the problem is described below.

Problem

Some providers reject empty text content blocks in request messages. Restored conversation history can replay empty streamed assistant text parts into the next provider request, causing the turn to fail before the model can continue.

What changed

  • Drop empty text content parts while projecting context history for LLM requests.
  • Keep the cleanup in the existing projector pass that skips partial messages and merges adjacent user messages.
  • Preserve assistant tool-call messages when their empty text content is removed, because the tool call itself is still meaningful.
  • Reject projected tool result messages if cleanup leaves them with empty content, rather than silently orphaning the preceding assistant tool call or synthesizing model-visible tool output.
  • Add projection coverage for empty text parts, assistant tool-call messages, malformed empty tool results, encrypted thinking parts, whitespace text, and non-mutating projection behavior.

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.

Validation

  • pnpm vitest run packages/agent-core/test/agent/context.test.ts
  • pnpm exec oxlint --type-aware packages/agent-core/src/agent/context/projector.ts packages/agent-core/test/agent/context.test.ts
  • git diff --check -- packages/agent-core/src/agent/context/projector.ts packages/agent-core/test/agent/context.test.ts
  • Read-only diff audit found no new internal identifiers, credentials, real endpoints, or other public-text leaks.

@changeset-bot

changeset-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a328707

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 19, 2026

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

commit: a328707

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1ff88012dd

ℹ️ 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".

Comment thread packages/agent-core/src/agent/context/projector.ts
@kermanx

kermanx commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator Author

@codex

1 similar comment
@kermanx

kermanx commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: a328707a78

ℹ️ 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".

@kermanx
kermanx merged commit 7644f10 into main Jun 19, 2026
9 checks passed
@kermanx
kermanx deleted the xtr/drop-empty-text-projection branch June 19, 2026 15:33
@github-actions github-actions Bot mentioned this pull request Jun 19, 2026
KevinChansGit pushed a commit to KevinChansGit/kimi-code that referenced this pull request Jun 22, 2026
upstream: 7644f10
Author: _Kerman <kermanx@qq.com>
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