Repository navigation
fix(kimi): omit empty assistant history on native Responses and keep Chat call/result pairs intact (supersedes #6931) - #6947
Conversation
…(carry #6931) Kimi Code's native Responses endpoint rejects a content-empty assistant message ("the message at position N with role 'assistant' must not be empty"). For the exact api.kimi.com/coding/v1/responses destination, the outgoing input now drops assistant messages whose content is "" or only empty text parts, keeping any message referenced by a same-input item_reference and any message with unknown fields. On the translated Chat wire, an empty assistant turn between a tool call and its result no longer splits the pair: it used to close the pending call with a synthetic "no tool result was recorded" message and turn the real result into an orphan. A standalone empty answer keeps its slot so chat templates with strict role alternation still accept the history. Co-authored-by: panyuanyuan <panyuanyuan@hetao101.com> Co-authored-by: yuanyuanlove <yuanyuanlove@users.noreply.github.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to No identified issue currently prevents merging; complete the normal test checks before merge. Pre-merge checks |
|
Summary
Supersedes #6931 (carried; the original author is credited in the trailers below). Lane L1 of the 2026-10-11 compatibility round also reviewed #6930 and #6675; both are left out because each needs an owner decision (see the end of this section).
Kimi Code native Responses no longer sends content-empty assistant history.
https://api.kimi.com/coding/v1/responsesrejects a request containing an assistant message with empty content (Invalid request: the message at position 585 with role 'assistant' must not be empty). For that exact host and path only, the outgoinginputnow omits assistant messages whose content is"",[], or only empty text parts. Whitespace, refusals, nonempty annotations, unknown parts or fields, reasoning items, tool calls and results are kept. An empty message referenced by a same-inputitem_referenceis kept so no reference dangles. Client history is not rewritten, and every other destination is unchanged.On the translated Chat wire, an empty assistant turn no longer splits a tool call from its result. Before,
function_call → assistant("") → function_call_outputclosed the pending call with a synthetic "no tool result was recorded" tool message, then turned the real result into an orphan with a second synthesized call. An empty turn (no text, tools or serialized reasoning) that arrives while calls await results is now dropped, so the real result stays attached. Outside that window, a standalone answer made of explicit blank text parts still serializes ascontent: "", so chat templates that require strict user/assistant alternation (for example Mistral's) keep accepting the history. This is narrower than #6931's original Chat change, which dropped every empty answer on allopenai-chatproviders; independent review found that it would have produced consecutive user turns on strict templates.Left out, as owner decisions:
Verification
tests/adapters/openai/openai-empty-assistant-history.test.ts, registered inscripts/test-layout/layout.jsonandtests/fixtures/test-layout-expected.json.bun run typecheck,bun run structure:check,bun run privacy:scan, andgit diff --check origin/devall pass.Checklist
Co-authored-by: panyuanyuan panyuanyuan@hetao101.com
Co-authored-by: yuanyuanlove yuanyuanlove@users.noreply.github.com
Summary by CodeRabbit