Skip to content

test: keep the replay golden independent of KIMI_CODE_DEBUG - #5412

Merged
liruifengv merged 1 commit into
release/2026-11-25from
fix/replay-golden-debug-env
Nov 25, 2026
Merged

liruifengv merged 1 commit into
release/2026-11-25from
fix/replay-golden-debug-env

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

Requirement or Bug

release/2026-11-25 上 ci: release packages (#5349) 的 CI 里,test (1) 挂在 tests/scenarios/replay.test.ts 的 [L0:kap.replay-recording]:tests/scenarios/recordings/first-turn/trace.json 与提交的 golden 有 18 处不同。这个 PR 让 replay golden 不再受运行者环境里的 KIMI_CODE_DEBUG 影响,并修好发版分支的 CI。

Bug Reproduction Steps

  1. 在 release/2026-11-25 上,不设 KIMI_CODE_DEBUG,运行 pnpm exec vitest run tests/scenarios/replay.test.ts。
  2. golden 比对失败:助手消息的第二帧 item.ended(带 debug)缺失,最终 turns 页面里助手消息的 debug 字段也缺失。

Root Cause

#5383 刷新 golden 时,运行环境里设置了 KIMI_CODE_DEBUG=1。kap-server 在这个变量为 1 时,会给每个 step 最后一个条目附加 debug(finish_reason、timing、usage),并多发一帧带 debug 的 item.ended(packages/kap-server/src/services/conversation/conversationFeed.ts 直接读 process.env)。这些数据进了 golden,而 CI 不设这个变量,所以每次都失败。

场景测试本来就不应该受本机调试开关影响,所以这次从测试侧修复:在场景测试的 setup 里清掉这个变量,golden 也不再含调试数据。这是根本修复,与服务端行为无关。

Code Changes

Behavior Changes and Affected Users

None。只改了场景测试的 setup 和 golden 数据,产品代码、配置、契约文件都没有改动。

验证情况:

  • 本地环境缺 Node 和依赖,pnpm qa:refresh replay、pnpm exec vitest run tests/scenarios/replay.test.ts、pnpm lint 和 pnpm run check:duplication 都未验证,靠这个 PR 的 CI 确认。
  • golden 是按 testkit stableJson 的格式(键排序、2 空格缩进、末尾换行)用脚本改的:脚本先确认能把原文件原样写回,再做删除。删除的内容与 CI 报告的 18 处差异一一对应。
  • 建议在本地再跑一次 KIMI_CODE_DEBUG=1 pnpm exec vitest run tests/scenarios/replay.test.ts,确认开着调试开关 golden 也能通过。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

The first-turn replay golden was refreshed with KIMI_CODE_DEBUG=1, so it
recorded an extra debug-only item.ended frame and item debug fields that CI
never produces. Clear KIMI_CODE_DEBUG in the scenario setup and drop the
debug-only data from the golden.
@changeset-bot

changeset-bot Bot commented Nov 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9cdd2bf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T10:31:44.224676Z 9cdd2bf PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Nov 25, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/MoonshotAI/kimi-code/@moonshot-ai/kimi-code@9cdd2bf
npx https://pkg.pr.new/MoonshotAI/kimi-code/@moonshot-ai/kimi-code@9cdd2bf

commit: 9cdd2bf

@liruifengv
liruifengv merged commit e9d21aa into release/2026-11-25 Nov 25, 2026
27 of 28 checks passed
@liruifengv
liruifengv deleted the fix/replay-golden-debug-env branch November 25, 2026 11:13
kimi-agent-bot pushed a commit that referenced this pull request Nov 25, 2026
The first-turn replay golden was refreshed with KIMI_CODE_DEBUG=1, so it
recorded an extra debug-only item.ended frame and item debug fields that CI
never produces. Clear KIMI_CODE_DEBUG in the scenario setup and drop the
debug-only data from the golden.
kimi-agent-bot pushed a commit that referenced this pull request Nov 25, 2026
The first-turn replay golden was refreshed with KIMI_CODE_DEBUG=1, so it
recorded an extra debug-only item.ended frame and item debug fields that CI
never produces. Clear KIMI_CODE_DEBUG in the scenario setup and drop the
debug-only data from the golden.
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