Skip to content

fix(source-control): decode Kimi generated text by selected format - #34237

Merged
brennanb2025 merged 9 commits into
mainfrom
brennanb2025/kimi-generation-output
Oct 27, 2026
Merged

brennanb2025 merged 9 commits into
mainfrom
brennanb2025/kimi-generation-output

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​399 $\color{#cf222e}{\Huge{\mathbf{−}}}$​38 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​361
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​398 $\color{#cf222e}{\Huge{\mathbf{−}}}$​90 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​308

The problem

With Kimi picked as the Source Control AI agent, Generate commit message filled the box with more than the message: Kimi's bullet (• ), plus anything Kimi printed before answering, such as a thinking line ("Simple request.") or the output of the user's Kimi hooks. In Kimi's plain-text output every line gets the same bullet, so Orca couldn't tell the answer from the rest.

What this PR changes

  • Kimi-generated commit messages, branch names, pull request titles and descriptions, conversation titles and Jira summaries now contain only Kimi's answer: no bullet, no thinking line, no hook output.
  • If Kimi returns output Orca can't read, generation fails with "Kimi returned output Orca couldn't read. Try again." instead of putting raw output in the box.
  • When Kimi fails, the error says what went wrong and what to do (for example: the session is in use in another Kimi client, a sign-in or model is missing, or a CLI argument was rejected) instead of only "Kimi CLI command failed with code N." The raw output is still kept for the existing diagnostics view.

How it works: Orca now asks Kimi for its machine-readable output (--output-format stream-json), where each line is a labelled message, and keeps the assistant's last answer. It reads output this way only when that format is in effect, so a user who sets --output-format text in their CLI arguments keeps the old behavior.

What stays the same

  • Other agents and custom commands are untouched, including when their answer happens to contain a line of JSON.
  • Settings, saved data and the UI layout don't change.

How it was tested

  • The real Kimi Code 2.3.1 CLI on Windows, run through Orca's own planning and answer-reading code, generated a clean commit message, branch name and pull request fields (QA ran on a830615).
  • Seven real Kimi failures (rejected or conflicting options, unknown command and others) each showed the right cause and fix. A real "session in use elsewhere" failure is replayed in tests.
  • Conversation titles and Jira summaries were checked against captured real Kimi output.
  • Automated tests cover the output reader, failure messages, command builder and all five places that use the answer. CI is green.
  • Not covered: the Electron app UI, a live SSH run, and Kimi's own hosted model service.

Tracked in STA-12141 and #33556.

Supersedes #33557 (kept @beduldul's commits).

beduldul and others added 2 commits October 26, 2026 20:15
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 (#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.
@brennanb2025
brennanb2025 marked this pull request as ready for review October 27, 2026 03:31
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 24 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 7e4e5675-540c-4781-bff7-0c29bb1cef2f
Commits

Reviewing files that changed from the base of the PR and between 2709c3b and 2bc92d3.

Files selected for processing: 17
  • src/main/text-generation/commit-message-text-generation-branch-name.test.ts
  • src/main/text-generation/commit-message-text-generation-generated-output.test.ts
  • src/main/text-generation/conversation-name-generation-request.test.ts
  • src/main/text-generation/jira-issue-summary-text-generation.test.ts
  • src/main/text-generation/kimi-generation-failure.test.ts
  • src/main/text-generation/kimi-generation-failure.ts
  • src/main/text-generation/source-control-agent-failure.ts
  • src/shared/__fixtures__/kimi-generation-source-shaped.ts
  • src/shared/__fixtures__/official-kimi-2.3.1-real-pr.jsonl
  • src/shared/__fixtures__/official-kimi-2.3.1-session-occupied.jsonl
  • src/shared/command-option-occurrence.ts
  • src/shared/commit-message-agent-spec.test.ts
  • src/shared/commit-message-agent-specs-secondary.ts
  • src/shared/commit-message-generation-options.ts
  • src/shared/commit-message-plan-kimi.test.ts
  • src/shared/commit-message-plan.ts
  • src/shared/kimi-generation-output.ts

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: b115431b-f45a-4eb4-a072-4d5e7efba4b5
Commits

Reviewing files that changed from the base of the PR and between 4fb099c and 2709c3b.

Files selected for processing: 3
  • src/main/text-generation/kimi-generation-failure.test.ts
  • src/shared/__fixtures__/kimi-generation-source-shaped.ts
  • src/shared/commit-message-plan-kimi.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.

Walkthrough

The changes add Kimi stream-JSON argument planning and output-format detection. Generation finalization now parses Kimi JSONL output and formats Kimi-specific failures. Tests cover Kimi output in commit-message, branch-name, conversation-name, and Jira-summary generation, along with literal JSON handling and failure cases.

Priority: Normal

Merge Risk: Minimal · previous review 2709c

The verified lint and formatting issues are resolved, and no concrete merge-blocking defect is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surv… 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: decoding Kimi-generated text according to the selected output format.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description is detailed and relevant. It explains the problem, user-visible changes, implementation approach, unchanged behavior, linked tracking references, and testing results. It does not repro…
Full details: Description check

Explanation

The description is detailed and relevant. It explains the problem, user-visible changes, implementation approach, unchanged behavior, linked tracking references, and testing results. It does not reproduce every template section, such as explicit Visual Proof, Review, Notes, and Checklist entries, but the missing sections are non-critical for this code-focused change.

Full details: Docstring Coverage

Explanation

Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 16 functions across 15 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • 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: 7


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: b34288ae-c18c-4db0-8762-6379b1248953
Commits

Reviewing files that changed from the base of the PR and between 3347d47 and a830615.

Files selected for processing: 11
  • src/main/text-generation/commit-message-text-generation-generated-output.test.ts
  • src/main/text-generation/conversation-name-generation-request.test.ts
  • src/main/text-generation/jira-issue-summary-text-generation.test.ts
  • src/main/text-generation/source-control-agent-failure.ts
  • src/shared/__fixtures__/kimi-generation-source-shaped.ts
  • src/shared/command-option-occurrence.ts
  • src/shared/commit-message-agent-spec.test.ts
  • src/shared/commit-message-agent-specs-secondary.ts
  • src/shared/commit-message-plan.test.ts
  • src/shared/commit-message-plan.ts
  • src/shared/kimi-generation-output.ts

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

Comment thread src/shared/commit-message-plan.test.ts Resolved
Comment thread src/shared/commit-message-plan.ts Resolved
Comment thread src/shared/commit-message-plan.ts Resolved
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Kimi-generated commit messages could contain presentation bullets, hook output, or pre-answer narration because the generation command requested text and shared cleanup could not distinguish an answer from protocol data. This change requests official Kimi Code stream-json and decodes it only when the effective execution plan selects that protocol. Commit messages, branch names, PR fields, conversation titles, and Jira summaries receive the decoded answer. Custom commands, explicit text overrides, and literal JSON from other providers keep their existing behavior.

The full review loop completed three rounds, including architecture, every-consumer, performance, fresh final reference, and readiness checks. It corrected unsafe shared autodetection, malformed-success fallback, occupied-session failure handling, argument-copy amplification, and parser-error matching. Kimi failures now give authored causes/remedies while preserving raw diagnostics for the existing diagnostic view. No open review finding remains. An existing other-provider raw-error-copy inconsistency is outside this change; speculative successful hook-only wrappers remain an unproven limitation, with no added output heuristic.

Validation:

  • Official unmodified @moonshot-ai/[email protected] on native Windows: actual planner → real CLI → finalizer → commit/branch/PR success at a830615, using the Responses load balancer and gpt-6.1-sol. Title/Jira evidence uses captured-output consumer checks; this does not claim a Moonshot-hosted backend, Electron UI, or live SSH run.
  • Seven real official parser failures passed at 4fb099c: conflicting/repeated agent options, missing operand, unknown flag, unknown command, and --auto conflict. Exact argv, exit status, stdout/stderr, authored remedy, and retained diagnostic copy were checked. All 16 exported streams roundtrip by hash, config hashes were unchanged, and no test process survived.
  • Later shipped changes are CLI/performance tests-row flows: c2f0dbd passed 190 focused tests; c6e17be passed 219; de179ee passed 228 across 12 named files; 42753e0 passed 43 affected failure tests and source-bound performance review. The compact real-planner20/200 operation assertion covers argument-copy growth; remaining progress bounds were reviewed in source.
  • Main merge 4fb099c changed none of the 17 PR paths. Commit 2709c3b contains only three test/fixture type annotations/import typing changes; production modules and captured bytes are unchanged. Final reference review explicitly covers 2709.
  • Final-head CI is green at 2709c3b: static analysis/typecheck, all five unit shards, packaging, and repository checks. One unchanged ACP backlog timing assertion failed initially and passed on the failed-job-only retry; no code change or test weakening was made. CI run, attempt 2. GitHub reports CLEAN, out of draft, and no unresolved review threads.

For Brennan’s review: this CLI/tests flow requires no screenshot. The three judgment points are effective format selection, strict selected success decoding, and status-first finalization.

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.

2 participants