Skip to content

fix(kosong): skip empty OpenAI-compatible reasoning stream values - #2508

Open
mangeshraut712 wants to merge 1 commit into
MoonshotAI:mainfrom
mangeshraut712:cursor/fix-kosong-skip-empty-think-7813
Open

fix(kosong): skip empty OpenAI-compatible reasoning stream values#2508
mangeshraut712 wants to merge 1 commit into
MoonshotAI:mainfrom
mangeshraut712:cursor/fix-kosong-skip-empty-think-7813

Conversation

@mangeshraut712

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • pnpm exec vitest run test/openai-legacy.test.ts test/kimi.test.ts in packages/kosong (178 passed)

Fixes #2506

Gateways that keep reasoning_content: "" after thinking ends were
journaling thousands of no-op think parts. Still observe the key for
dialect detection; only yield think parts with non-empty text (fixes MoonshotAI#2506).
@changeset-bot

changeset-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1ce0e7e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/kosong Patch
@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

@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: 1ce0e7ec0f

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 450 to +451
const reasoning = reasoningKeyDialect.observe(delta);
if (reasoning !== undefined) {
if (reasoning) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply the empty-reasoning guard to agent-core-v2

When requests run through kimi web, kap-server, or an explicitly enabled v2 CLI, this change is bypassed because those paths use packages/agent-core-v2/src/kosong/provider/bases/openai/openai-legacy.ts, whose stream conversion still yields a think part whenever reasoning !== undefined; the v2 Kimi provider also composes this OpenAI base. Consequently, gateways that emit reasoning_content: "" after thinking still bloat the journal in these product paths despite the Kimi Code changeset, so the equivalent guard and coverage need to be added to the v2 implementation.

AGENTS.md reference: AGENTS.md:L28-L28

Useful? React with 👍 / 👎.

@pkg-pr-new

pkg-pr-new Bot commented Aug 1, 2026

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

commit: 1ce0e7e

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.

[kosong] OpenAI-compatible stream parser journals an empty think part per chunk carrying reasoning_content: ""

1 participant