Skip to content

fix(source-control): keep only the answer from Kimi text mode - #33557

Closed
beduldul wants to merge 1 commit into
stablyai:mainfrom
beduldul:fix/kimi-text-mode-bullets
Closed

beduldul wants to merge 1 commit into
stablyai:mainfrom
beduldul:fix/kimi-text-mode-bullets

Conversation

@beduldul

@beduldul beduldul commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Kimi prints a few lines before it answers — a thinking line, and whatever your hooks print — and every one of those lines starts with a bullet, including the answer. Orca only removed the bullet from the very first line, so the thinking line and the hook output ended up in the commit message box.

The text alone cannot tell you where the preamble ends, because the answer is bulleted too. So this asks Kimi for its machine-readable output instead, where each line is a labelled message and the last one from the assistant is the answer.

What Changed

Before, with Kimi selected as the commit-message agent, pressing Generate commit message filled the box with

Simple request.
• docs: add README.md

After, it fills the box with

docs: add README.md

Two changes:

  1. commit-message-agent-specs-secondary.ts — the Kimi recipe now passes --output-format stream-json after --prompt.
  2. commit-message-agent-output.ts — cleanGeneratedCommitMessage reads the last {"role":"assistant"} line and uses its content. A multi-line answer stays a multi-line answer.

Why

I first tried to fix this in the text cleaner by keeping only the last bulleted line. That is wrong, and CodeRabbit caught it on this PR: if the answer itself is • feat: add parser / • handles nested input, keeping the last line throws away the subject. The text mode gives no way to separate preamble from answer, so the fix belongs in how Kimi is invoked.

--output-format stream-json is the mode the CLI reference documents for exactly this: one JSON message per line, {"role":"assistant","content":"…"} for answers, {"role":"tool",…} for tool results, so the last assistant message is the answer.

--final-message-only would have been simpler, but it belongs to --print mode, and kimi-code rejects --print — this repo already recorded that in #11669, which is why the recipe uses --prompt.

The parser scans line boundaries with indexOf instead of String.split('\n'), because splitGeneratedCommitMessage has a test that fails if the generated body is split into a line array.

Two review findings changed the shape of that parser. A body only counts as stream output when every non-empty line is a record with a string role, so another agent's answer that happens to contain a JSON line — fix: document the payload followed by {"role":"assistant","content":"example"} — keeps its subject instead of being replaced by example. And a recognized stream with no assistant message now returns an empty string rather than the tool records, so a run that produced no answer reads as a failure instead of putting JSON in the box.

Linked Issue

Fixes #33556

Visual Proof

N/A — the change is in the shared string cleaner and the agent recipe behind the commit-message box. No component or layout changed; the box renders whatever string the cleaner returns.

Testing

pnpm test src/shared/commit-message
pnpm test src/shared
pnpm tc:node
npx oxlint src/shared/commit-message-agent-output.ts src/shared/commit-message-agent-specs-secondary.ts

All pass: 160 tests across the four commit-message suites, 16,028 across src/shared, typecheck clean, lint clean. Four of the new assertions fail on main — the recipe expectation, both stream-json parsing cases, and the tool-only stream that must yield nothing.

Not verified: I do not have a Kimi CLI on this machine, so I could not run kimi --prompt … --output-format stream-json end to end. The flag, its --prompt-only constraint and the message shape come from the Kimi Code CLI reference, and the parser is tested against that documented shape. If the real output differs, the recipe change is the part to check first.

AI Disclosure

Written by Claude in a Hermes agent session. The reporter's diagnosis in #33556 pointed at stream-json; the parser, the tests and the analysis above are mine.

Review

  • Cross-platform: string handling and argv only; no path, process or platform API touched.
  • SSH/remote/local: no assumptions about where the agent binary runs.
  • Agent/integration compatibility: only the Kimi recipe changes. The parser runs for every agent but only consumes lines that parse as JSON with role: "assistant", so a jcode --json envelope or plain text falls through unchanged — the other agents' suites still pass.
  • Performance: one linear scan over the body, no line array allocated. The existing splitGeneratedCommitMessage performance test, which asserts String.split('\n') is never called, passes.
  • UI quality: no UI change.
  • Security: no new input surface. The parser only reads the agent's stdout; it does not execute anything from it.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: nothing to flag.
  • Backwards compatibility: agents other than Kimi are unaffected. For Kimi, the invocation gains one flag and the output format changes, which is the point of the fix.
  • A partial or interleaved JSON line is skipped rather than parsed, so a truncated write cannot become the commit message.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c873b8f4-f0de-45fe-af48-27a94611df8e
Commits

Reviewing files that changed from the base of the PR and between b9c710cbb5244075fffdf177659be33a68702e61 and 7df16e5.

Files selected for processing: 2
  • src/shared/commit-message-agent-output.ts
  • src/shared/commit-message-prompt.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

Kimi’s arguments now request stream-json output. The commit-message cleaner scans newline-delimited JSON records and uses the content of the last assistant message with string content when it recognizes a complete stream. An assistant message with non-empty tool_calls clears the answer. A recognized stream without an answer produces an empty string. Input that does not qualify as a stream follows the existing cleanup path. Tests cover last-message selection, tool calls, multiline content, and plain commit text containing JSON records.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 7df16

Kimi commit-message output now follows the intended stream-JSON handling. No identified issue remains that should prevent merging after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: retaining only the answer from Kimi output. It is concise and related to the pull request.
Description check Passed The description includes the required sections, linked issue, user-facing behavior, rationale, testing results, limitations, compatibility notes, and checklist context. It is complete enough for revie…
Linked Issues check Passed Issue #33556 requires Kimi commit-message generation to exclude pre-answer output and bullet prefixes. The Kimi recipe requests --output-format stream-json. cleanGeneratedCommitMessage recognizes …
Out of Scope Changes check Passed The changes remain within issue #33556. They modify the Kimi commit-message arguments, the shared commit-message cleaner, and focused tests for those behaviors. The cleaner preserves non-stream text a…
Full details: Description check

Explanation

The description includes the required sections, linked issue, user-facing behavior, rationale, testing results, limitations, compatibility notes, and checklist context. It is complete enough for review, although some checklist items remain unchecked.

Full details: Linked Issues check

Explanation

Issue #33556 requires Kimi commit-message generation to exclude pre-answer output and bullet prefixes. The Kimi recipe requests --output-format stream-json. cleanGeneratedCommitMessage recognizes complete stream records and uses the content of the last assistant message. The reported tests cover preamble removal, tool-only output, multiline answers, and preservation of plain text. The Kimi CLI was not run end to end, but the implementation and automated tests match the issue's documented stream format.

Full details: Out of Scope Changes check

Explanation

The changes remain within issue #33556. They modify the Kimi commit-message arguments, the shared commit-message cleaner, and focused tests for those behaviors. The cleaner preserves non-stream text and does not alter unrelated agent or UI behavior. No unrelated change is demonstrated.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 85274f08-cda2-466a-a039-0d135a9d136c
Commits

Reviewing files that changed from the base of the PR and between 6458c08 and 453fbec18a4bdd3e81a72a3b9838f09378158dff.

Files selected for processing: 2
  • src/shared/commit-message-agent-output.ts
  • src/shared/commit-message-prompt.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@beduldul
beduldul force-pushed the fix/kimi-text-mode-bullets branch from 453fbec to 155b620 Compare October 25, 2026 15:05

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 55377a63-ec67-4c8c-8e8b-e4bc9babb664
Commits

Reviewing files that changed from the base of the PR and between 453fbec18a4bdd3e81a72a3b9838f09378158dff and 155b620a144b221d2b683b64294a06e1b79b8b23.

Files selected for processing: 4
  • src/shared/commit-message-agent-output.ts
  • src/shared/commit-message-agent-spec.test.ts
  • src/shared/commit-message-agent-specs-secondary.ts
  • src/shared/commit-message-prompt.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@beduldul
beduldul force-pushed the fix/kimi-text-mode-bullets branch from 155b620 to b9c710c Compare October 25, 2026 16:46

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e04aa0c5-ddfa-4b71-933e-a11308a4a2d8
Commits

Reviewing files that changed from the base of the PR and between 155b620a144b221d2b683b64294a06e1b79b8b23 and b9c710cbb5244075fffdf177659be33a68702e61.

Files selected for processing: 2
  • src/shared/commit-message-agent-output.ts
  • src/shared/commit-message-prompt.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Kimi Code's text mode prefixes thinking and hook output with a bullet, so the
commit message arrived mixed with narration. The recipe now asks for
--output-format stream-json and the answer is taken from the last assistant
record, which is the commit message (stablyai#33556).

A record that requests a tool is narration rather than an answer, so it clears
the candidate: a stream that ends on a tool call yields no answer, which
finalizeFromAgentOutput already treats as a failed run. Only a body whose every
non-empty line is a record counts as stream output, so a plain answer that
happens to contain a JSON line is left alone.
@nwparker

Copy link
Copy Markdown
Contributor

Thanks for this fix! The same problem is now fixed on main by #34237 (47018d4): the Kimi recipe passes --output-format stream-json and the output is decoded as the latest assistant message without tool_calls, so bullets, thinking lines, and hook output no longer reach the generated text. Closing as superseded — thanks again for the contribution.

@nwparker nwparker closed this Oct 28, 2026
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.

Source Control AI: Kimi commit messages include Kimi's text-mode output (• prefix, pre-answer lines)

2 participants