Repository navigation
fix(agent-core-v2): compare working directories as paths before sending the date reminder - #5576
Merged
Merged
Conversation
…ng the date reminder
🦋 Changeset detectedLatest commit: c84661e The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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: |
This was referenced Nov 27, 2026
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Dec 2, 2026
`bun scripts/upstream-ledger.mjs --refresh` at upstream/main 4eb2919 added 126 rows, so every open upstream commit and every PR it references now has a ledger row: 0/596, down from 125 at 8bf8ba3 and 126 at the fetched tip. The refresh only reads `upstream/main ^ main`, so the three release-2.6.2 commits named by the mission (MoonshotAI#4875/MoonshotAI#4905/MoonshotAI#4922) gained rows with the refresh's row shape. Settled with live probes in this tree: - ported: MoonshotAI#5533 (docs 2.8.1 changelog), MoonshotAI#4875 (registry search_url and feedback_url plus the feedback service), MoonshotAI#4905 (Kimi upload status validation in packages/core), MoonshotAI#4922 (swarm task events in sessionTaskFeed), MoonshotAI#5438 (unload only declared dynamic tools), MoonshotAI#5592 (dynamic tool replacement order), MoonshotAI#5595 (append-log known length), MoonshotAI#5573 (skill roots for every work dir), MoonshotAI#5576 (date reminder cwd comparison), MoonshotAI#5618 (session titles for skill openers), MoonshotAI#5638 (frozen loop tool baseline), MoonshotAI#5626 (legacy turn-input origins) - partial: MoonshotAI#5505 (processLiveness source and consumers present; the upstream unit test file was never carried), MoonshotAI#5571 (program-resume and OSC 7577 present; the upstream test helper was never carried), MoonshotAI#5532 (gitService half present; fsService still leaks the environment lease at fsService.ts:1133 and :1267), MoonshotAI#5557 (app-client icon registry kept; the move to app-ui was never carried) - not-applicable: MoonshotAI#4655 (upstream reverted auto review in MoonshotAI#5649), MoonshotAI#5333 (PLAYBOOK:111 deliberate flat experimental flags) M39's "likely present" list was checked, not trusted: MoonshotAI#5438 is present (upstream test passes), MoonshotAI#5487 is not (nativeStartSettleMs/leg.nativeSettled absent), MoonshotAI#5635 is not (ToolsSettled absent), MoonshotAI#5429 needs a visual probe. The remaining 194 pending rows stay open with their reasons; no feature was ported and no upstream-drift allowlist entry was added. Verification: verify -> 332 closed rows, 332 carry every file of their PR; 317 probes pass, 2 foreign-runner skips, 0 fail; a second verify is byte-identical (ledger sha256 cbf53638...). Probe tests 29 pass; bun run lint and node scripts/checks/ratchet.mjs green.
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
在 Windows 上,从终端启动的会话(TUI、print 模式),以及 SDK 用户建的会话,模型从来收不到「今天的日期」这条提醒,跨过午夜也收不到「日期变了」。模型只能靠训练数据猜日期,用户收不到任何信号:没有报错,也没有日志。#5570 加的 E5 场景(
tests/e2e/scenarios/cache/date-change-keeps-the-prefix.spec.ts)第一次在 CI 的 Windows 作业上跑,就发现了这个问题。Bug Reproduction Steps
Today's date is …这条提醒。CI 上的复现:#5570 的 Windows tui 作业,E5 场景断言第一次请求的提醒里有本地日期,实际提醒是空的。同一个场景在 Linux 的 TUI、Windows 的 ACP、Desktop、Web 上都通过。
Root Cause
日期提醒有一道判断:只有在「system 渲染时的 cwd」和「当前 cwd」是同一个目录时才发,否则说明 system 是为别的目录渲染的,先不发。这道判断从一开始就用字符串
!==比较,而两边在 Windows 上的写法不同:normalizeWorkDir把工作目录改成正斜杠,会话的 cwd 就是这个值C:/Users/me/projectEnvironmentWorkspaceView用本机环境的路径模块(Windows 上是node:path/win32)做resolveC:\Users\me\project两者永远不相等,判断就把日期提醒当成「不属于当前目录」静默丢掉。ACP、Desktop、Web 不经过 SDK 的正斜杠归一,Linux 和 macOS 只有正斜杠,所以只有 Windows 上经 SDK 建的会话受影响。
这是根本修复:判断的用意不变,只是把「是不是同一个目录」从字符串相等改成路径等价。
Code Changes
sameDir是引擎里现成的目录比较(packages/agent-core-v2/src/_base/utils/workdir-slug.ts,工作区根目录也用它):先规范化路径,统一斜杠方向、去掉末尾斜杠,Windows 形状的路径不分大小写。阅读顺序:
packages/agent-core-v2/src/features/dateChange/dateChangeService.ts的belongsToCurrentCwd();packages/agent-core-v2/test/features/dateChange/dateChangeInjection.test.ts新增的AgentDateChangeService on a Windows session cwd。Behavior Changes and Affected Users
.和重复斜杠提示词:两句提醒的文字都没改(
Today's date is …、The date has changed. Today's date is now …),变化的是收到它们的人群:Windows 上的 TUI、print 模式和 SDK 会话从此能收到。这两句原来就约束「以最新的日期提醒为准,不要主动告诉用户」,现在对这个人群同样生效。旧会话:Windows 上升级前建的会话恢复后,下一步会补一条「今天的日期」提醒,追加在历史末尾,不改写已有的请求前缀。
覆盖:
AgentDateChangeService on a Windows session cwd:会话 cwd 是 SDK 写法C:/Users/me/project、或者盘符是小写c:\…,渲染的 cwd 是C:\Users\me\project时,第一步发今天的日期,拨动时钟后发「日期变了」。修复前这 2 条都失败,提醒是空的,和 CI 上的现象一致。另有 1 条:真的是另一个 Windows 目录时一条都不发,证明判断的用意还在。原有的「为别的目录渲染时不发」「渲染的 cwd 为空时照发」用例继续通过。验证:见折叠块。
运行的命令和结果
基线是 main
f94b9a2f3,在 macOS 上跑。单测直接构造 Windows 写法的路径字符串,不依赖本机平台;Windows 上的真实行为交给本 PR 的 Windows E2E 作业。expected [] to deeply equal [ StringContaining "2026-07-29" ]),修复后通过。pnpm exec vitest run跑packages/agent-core-v2/test/features/dateChange、test/session/agentLifecycle/agentLifecycle.test.ts、test/agent/profile、test/app/config/config.test.ts、test/agent/environmentBinding、test/features/reminder、test/remote和packages/kap-server/test/prompts.test.ts:21 个文件 637 条通过。pnpm lint:通过。pnpm exec tsc -p packages/agent-core-v2/tsconfig.json --noEmit:通过。pnpm run check:duplication f94b9a2f3:没有新增重复。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.