Skip to content

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

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

mangeshraut712 wants to merge 33 commits 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

@changeset-bot

changeset-bot Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c3d2b82

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

@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 thread packages/kosong/src/providers/openai-legacy.ts Outdated
@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@c3d2b82
npx https://pkg.pr.new/@moonshot-ai/kimi-code@c3d2b82

commit: c3d2b82

@HelloWorldU HelloWorldU 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.

Test that empty reasoning fields still preserve dialect detection

@mangeshraut712

Copy link
Copy Markdown
Contributor Author

@HelloWorldU the dialect-preservation test you asked for is in this PR now.

packages/agent-core-v2/test/kosong/provider/composition.test.ts (reasoning dialect (behavior probes)) plus the kosong openai-legacy / kimi tests: empty streaming reasoning / reasoning_content fields do not yield think parts, and outbound dialect detection is still preserved.

Latest commit fbd9069b, CI green.

@cursor
cursor Bot force-pushed the cursor/fix-kosong-skip-empty-think-7813 branch 3 times, most recently from 02411ed to fad96f5 Compare September 6, 2026 14:35

@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: 7b6f3a494a

ℹ️ 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 thread .changeset/kosong-skip-empty-think.md Outdated
@mangeshraut712
mangeshraut712 force-pushed the cursor/fix-kosong-skip-empty-think-7813 branch 2 times, most recently from fc94e1e to 193c36f Compare September 6, 2026 14:46
@cursor
cursor Bot force-pushed the cursor/fix-kosong-skip-empty-think-7813 branch 3 times, most recently from 38a4c7e to 4a95738 Compare September 14, 2026 05:20

@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: 4a9573838c

ℹ️ 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 .changeset/kosong-skip-empty-think.md Outdated
@cursor
cursor Bot force-pushed the cursor/fix-kosong-skip-empty-think-7813 branch 2 times, most recently from 4605edb to 648f97a Compare September 16, 2026 05:06
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).
The kosong provider copy was removed when the human LLM layer landed.
Apply the same empty-reasoning skip on the OpenAI chat-completions stream parser.
Match other server tests so afterAll does not fail with ENOTEMPTY when
events are still being flushed.
List only the published CLI package and describe the user-visible behavior.
@cursor
cursor Bot force-pushed the cursor/fix-kosong-skip-empty-think-7813 branch from bbbcd19 to afbd929 Compare September 21, 2026 04:32
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@mangeshraut712

Copy link
Copy Markdown
Contributor Author

@HelloWorldU the dialect-preservation test is on the branch. Could you or another maintainer say whether that covers the review, or what still needs to change? I will leave the branch alone until then.

mangeshraut712 and others added 2 commits September 30, 2026 10:36
Confirm the CLI-scoped, user-facing kosong-skip-empty-think changeset on the branch so CI re-runs after the review replies.
@cursor
cursor Bot force-pushed the cursor/fix-kosong-skip-empty-think-7813 branch from 5edd79e to beaf861 Compare September 30, 2026 05:22
Co-authored-by: Mangesh Raut <mangeshraut712@users.noreply.github.com>

@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: af4c90d27a

ℹ️ 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/kosong/src/providers/openai-legacy.ts Outdated
Dropping every empty reasoning delta also dropped the only marker when a
tool call came back with reasoning_content: "", so the next request
omitted reasoning_content. Keep the first empty marker per message and
drop only the repeats, in the Kimi, OpenAI legacy and v2 parsers.

@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: bbb8173eb4

ℹ️ 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/kap-server/test/search/searchService.test.ts Outdated
mangeshraut712 and others added 4 commits October 14, 2026 04:18
After bbb8173 the first empty reasoning delta in a message is kept as the marker, so the resume test now expects it ahead of the later non-empty reasoning.

@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: 4d2ee492df

ℹ️ 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 .changeset/kosong-skip-empty-think.md Outdated
Comment thread packages/agent-core-v2/src/human/llm/requester/bases/openai/format.ts Outdated

@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: 5e81e9adce

ℹ️ 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-v2/src/human/llm/requester/bases/openai/format.ts Outdated
MANGESH RAUT and others added 2 commits October 15, 2026 14:51
…rs it

An empty reasoning field on a text delta is deferred behind pending text
and then dropped. Retain that key only once the marker cannot be discarded,
and replay it ahead of a tool call in the same chunk so follow-up requests
still send the field.

@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: 06c0fecb49

ℹ️ 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-v2/src/human/llm/requester/bases/openai/format.ts Outdated

@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: 43928eef1b

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

@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: 70c2f6f653

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

@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: 711e4d453f

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

@mangeshraut712

Copy link
Copy Markdown
Contributor Author

@HelloWorldU Confirmed on 8973a5d: packages/kosong/test/kimi.test.ts contains "keeps one empty reasoning marker and preserves later non-empty deltas." It begins with an empty streamed reasoning field and verifies the next request serializes under reasoning rather than the default reasoning_content. I ran that test directly: 1 passing.

@mangeshraut712

Copy link
Copy Markdown
Contributor Author

@HelloWorldU Could you please review the latest push, 8973a5d? It is the final requested update for the deferred empty-reasoning tool-call case; no additional Codex review round will be triggered.

This branch has not been deployed

No deployments
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: ""

3 participants