fix(agent-core-v2): caller MCP servers and skill dirs parity - #1636
Conversation
…reate - add mcpServers to CreateSessionOptions, forwarded to the session's first ensureMcpReady call so caller-supplied servers ride on the initial load - ensureMcpReady accepts callerServers, honored only by the call that starts the initial load; later calls just await the in-flight single-flight load - merge precedence mirrors v1 (rpc/core-impl.ts): file config < caller-supplied < plugin servers
- add extendWorkspaceWithSkillRoots to path-access; Read/Write/Edit/Grep/ Glob and media tools merge skill-catalog roots into the workspace per call (v1 merged once at construction), so skill dirs outside the cwd stay reachable and late-loading roots are picked up - add skillCatalogRuntimeOptionsSeed; wire --skillsDir into the v2 print CLI and skillDirs into kap-server startServer (v1 SDK skillDirs parity)
🦋 Changeset detectedLatest commit: 27392a5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 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 |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27392a5a09
ℹ️ 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".
| // Optional so unit tests that construct the tool directly (bypassing DI) | ||
| // keep working; always registered in production scopes. |
There was a problem hiding this comment.
Move v2 implementation comments to the file header
In the packages/agent-core-v2 scope, the nearest AGENTS.md comment convention says comments must live solely in the top-of-file /** */ block and never beside functions, methods, or statements. This newly added constructor comment (and the same pattern in the other touched v2 tool files) violates that contract, so please remove it or move any durable rationale into the file header.
Useful? React with 👍 / 👎.
Related Issue
No linked issue — the two problems are explained below.
Problem
Two declared-but-disconnected surfaces in the v2 engine (experimental, behind
KIMI_CODE_EXPERIMENTAL_FLAG):CreateSessionPayload.mcpServersis part of the declared RPC payload andmergeCallerMcpServerswas ported with tests, butCreateSessionOptionshad no such field and the session's initial MCP connect only merged file config + plugin servers. SDK / embedding-host callers passing MCP servers at session creation lost them without any error.~/.kimi-code/skillsstay reachable; v2 computed the same roots but nothing consumed them. Separately, the v2 runtime-options mechanism for explicit skill dirs (v1's SDKskillDirs) was fully implemented but no production composition root ever set it — only tests did.What changed
Caller MCP servers (parity with v1
rpc/core-impl.ts)CreateSessionOptionsgainsmcpServers; session materialization forwards it to the session's firstensureMcpReadycall — the one that starts the initial MCP load (later calls, e.g. from agent creation, only await the in-flight load).Skill directories (parity with v1
extendWorkspaceWithSkillRoots+ SDKskillDirs)extendWorkspaceWithSkillRoots; Read/Write/Edit/Grep/Glob and ReadMediaFile merge skill-catalog roots into their workspace per execution (v1 merged once at tool construction), so roots added late by plugin reloads are picked up too.startServer({ skillDirs })for embedding hosts, and--skillsDirin the v2 print CLI.Tests: unit coverage for the merge helper, the MCP merge precedence + single-flight behavior, a Read-tool relative-traversal-into-skill-root case, and seed-wiring tests for both composition roots (kap-server boot + v2 print CLI).
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.