fix(agent-core-v2): temporarily disable skill-root directory watches and add detailed startup tracing - #3690
fix(agent-core-v2): temporarily disable skill-root directory watches and add detailed startup tracing#3690liruifengv wants to merge 2 commits into
Conversation
The skill-root watches added in #3608 register recursive fs.watch roots on the entire OS home directory and the whole project root. On Windows these run through the native recursive leg, which delivers every subtree event to the main thread with no OS-level filtering, and each event costs an xstate transition (#3502). This is the prime suspect behind the reported 0.42.0 startup and interactive lag on Windows. Gate both watch sites behind KIMI_CODE_SKILL_ROOT_WATCH (default off) until the watches are redesigned to cover only the skill candidate directories. Skill catalogs still load at startup; new or changed skills are picked up on restart.
🦋 Changeset detectedLatest commit: 5c2639a 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 |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c2639a9f6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| "@moonshot-ai/kimi-code": patch | ||
| --- | ||
|
|
||
| Disable live watching of skill directories; new or changed skills are picked up on restart. Set KIMI_CODE_SKILL_ROOT_WATCH=1 to re-enable live refresh. |
There was a problem hiding this comment.
Keep the changeset entry to one sentence
When release tooling publishes this entry, it will include two sentences and expose the temporary environment-variable mechanism, although repository policy requires one short user-facing sentence stating only what changed. Fold the relevant user-visible behavior into a single sentence and omit mechanism-level detail.
AGENTS.md reference: AGENTS.md:L86-L87
Useful? React with 👍 / 👎.
Related Issue
No linked issue — the problem is explained below (reported by Windows users on 0.42.0).
Problem
Windows users report that the latest CLI (0.42.0) starts very slowly and feels laggy throughout the session. A
KIMI_STARTUP_TRACE=1capture from an affected machine shows ~2.5s in the win32-only Git Bash probe and 15.3s insidegetWorkspaceTrustInfo(workspace materialization) before the first screen.One of the 0.42.0 changes in this area is #3608, which added recursive file watches on the entire OS home directory and the whole project root to keep the skill catalog fresh. On Windows these run through the native recursive
fs.watchleg (#3502), which delivers every subtree event to the main thread with no OS-level filtering — the home directory is one of the most active trees on a Windows machine (Defender, search indexer, browser caches, OneDrive), so the main thread is continuously interrupted. There is currently no config, env var, or flag to turn these watches off.What changed
UserFileSkillSource— user-level roots under the OS home directory, andWorkspaceRootSkillSource— the project root) are now gated behindKIMI_CODE_SKILL_ROOT_WATCH(default off) until the watches are redesigned to cover only the skill candidate directories instead of the whole home/project tree. Skill catalogs still load normally at startup; newly added or changed skills are picked up on restart. SetKIMI_CODE_SKILL_ROOT_WATCH=1to re-enable live refresh.startupTracepoints along the workspace-trust path so the remaining startup cost can be split precisely on the affected machine:workspaceTrust:getOrCreate:*/workspaceTrust:read:*(SDK),workspace:catalog:*/workspace:materialize:*(engine). The engine-side tracer lives in agent-core-v2 and shares the same env vars (KIMI_STARTUP_TRACE/KIMI_STARTUP_TRACE_LOG), the same log file, and the same process-start clock as the app-side tracer (the app tracer now uses rawperformance.now()so app and engine labels are directly comparable).KIMI_CODE_SKILL_ROOT_WATCH=1; two new tests cover the default-off behavior for both watch sites.Checklist
gen-changesetsskill.gen-docsskill, or this PR needs no doc update — skill watching was not documented, and theKIMI_CODE_SKILL_ROOT_WATCHkill-switch is temporary.