Repository navigation
fix(agent-core-v2): reject repeated model responses - #4977
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 2a75539 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Codex Review Summary: ✅ CompletedThis 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. |
commit: |
7Sageer
approved these changes
Nov 16, 2026
Merged
kimi-agent-bot
pushed a commit
that referenced
this pull request
Nov 16, 2026
* fix(agent-core-v2): reject repeated model responses * chore: add changeset for repeated model responses --------- Co-authored-by: 7Sageer <[email protected]>
6 tasks done
wbxl2000
pushed a commit
that referenced
this pull request
Nov 17, 2026
* fix: resume sessions with removed default models (#4982) * fix(node-sdk): resume sessions with missing default model * fix(cli): check auth for the resumed session model * chore: add changeset for unavailable model recovery * fix(agent-core-v2): stop rebuilding mismatched session indexes (#4980) * fix(agent-core-v2): reject repeated model responses (#4977) * fix(agent-core-v2): reject repeated model responses * chore: add changeset for repeated model responses --------- Co-authored-by: 7Sageer <[email protected]> * fix(agent-core-v2): inline deferred tools without dynamic loading (#4971) * fix(agent-core-v2): record restored task notifications without model requests (#4949) (#4989) * fix(agent-core-v2): record restored task notifications without model requests - queue restored task notifications as prompt-only turns after loop initialization - preserve interrupted and queued turns during resume and fork - complete reconciliation before initialization and reset return to keep Wire reads ordered - run loop and container cleanup when reconciliation fails - surface restored notification persistence failures * chore: add changeset for restored task notifications * fix(agent-core-v2): restore overflow recovery after LLM retries (#4950) (#4990) * fix(agent-core-v2): restore step state after LLM retries * test(agent-core-v2): scope retry event to overflow regression * fix(config): allow sessions with invalid user config (#4951) (#4991) * fix(agent-core-v2): tolerate config read failures for permission rules * chore: add changeset for permission config recovery * docs: document permission config recovery * docs: qualify permission config recovery scope * fix(config): surface read error diagnostics * fix(config): allow sessions with invalid user config * fix(config): preserve valid values and replay diagnostics * fix(config): remove startup diagnostic replay * fix(agent-core-v2): ignore non-user prompts during Tower wake (#4952) (#4992) * fix(agent-core-v2): ignore non-user prompts during Tower wake * chore: add Tower notification fix changeset * fix(agent-core-v2): preserve slash prompts during Tower wake * fix(agent-core-v2): route foreground shell events by origin (#4954) (#4994) * fix(agent-core-v2): route foreground shell events by origin * test(agent-core-v2): expect tool event origins in snapshots * fix(klient): accept tool events from pre-origin hosts * fix(agent-core-v2): run external Stop hooks after turn completion (#4956) (#4995) * fix(agent-core-v2): run external Stop hooks after turn completion * chore: add changeset for external Stop hooks * docs: clarify post-turn Stop hook timing * fix(agent-core-v2): wait for subagent quiescence (#4953) (#4993) * fix(agent-core-v2): reject incomplete model streams (#5006) * fix(agent-core-v2): preserve choice-level OpenAI token usage (#5017) * fix(capability): confirm stopping WebBridge before Windows updates (#4999) * fix(capability): confirm stopping WebBridge before Windows updates * fix(capability): harden WebBridge update recovery * fix(capability): restore WebBridge after startup failure * fix(capability): wait for WebBridge process exit * fix(capability): handle WebBridge confirmation edge cases --------- Co-authored-by: kimi-agent-bot <[email protected]> Co-authored-by: kimi-agent-bot <[email protected]> * chore: sync release 2.6.3 back to main * chore: finish release 2.6.3 backsync * chore: sync node-sdk lockfile importer * fix(sdk): preserve main core type dependencies * fix: complete release 2.6.3 backsync --------- Co-authored-by: Haozhe <[email protected]> Co-authored-by: 7Sageer <[email protected]> Co-authored-by: kimi-agent-bot <[email protected]> Co-authored-by: kimi-agent-bot <[email protected]>
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requirement or Bug
使用 OpenAI Chat-compatible provider 时,模型可能以
finish_reason: repeat结束响应。此前,只要响应带有文本或工具调用,Kimi Code 就可能把它当成有效回复并结束请求;本 PR 将这类响应改为可重试失败,避免把重复输出作为有效结果接受。未提供关联 issue;本次问题来自 release 分支缺陷反馈。
Bug Reproduction Steps
choices[0].finish_reason = "repeat"。done,上层把该响应当作有效回复。empty_response失败;普通文本和工具调用响应仍返回done。回归测试直接构造上述原始 OpenAI chunk,并分别覆盖文本、工具调用和上层错误转换。
Root Cause
OpenAI 解码器将未识别的
repeat归一化为finishReason: "other",同时在rawFinishReason中保留原始值。请求结算此前只检查空内容和纯 thinking 内容,没有检查rawFinishReason,因此非空的重复输出会穿过有效性判断。这是根本修复:在共用请求结算边界拒绝
rawFinishReason === "repeat"的响应,而不是在特定 provider 或 UI 上绕过。Code Changes
APIEmptyResponseError转换沿用现有机制,不扩大FinishReason类型。@moonshot-ai/kimi-codepatch changeset:Treat model responses stopped for repeated output as retryable failures.Behavior Changes and Affected Users
repeat的响应done接受empty_response失败repeat的 OpenAI Chat-compatible provider(包括 Kimi)并依赖重复输出作为最终回复的用户Anthropic 与 OpenAI Responses 解码路径在原始结束原因同样为
repeat时也由共用结算边界覆盖;本 PR 的直接协议回归使用 OpenAI Chat 输入,未声称对这些服务端做过真实在线复现。empty-response.test.ts和modelRequester.test.ts覆盖,包含生产结算与上层错误转换。验证明细
done,恢复后返回failed。release/2026-11-16@origin):3 个测试文件共 26/26 通过。agent-core-v2typecheck 通过。corepack pnpm run build通过。check-no-comments:1864 个文件通过。empty-response.test.ts3 → 3,modelRequester.test.ts14 → 14。Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.