Skip to content

Stop kimi runs from seeing other projects' MCP servers, threads and memory (#671) - #674

Merged
currentbits merged 2 commits into
mainfrom
coder/fork-we-have-an-issue-with-cross-contami-d6e244
Aug 22, 2026
Merged

currentbits merged 2 commits into
mainfrom
coder/fork-we-have-an-issue-with-cross-contami-d6e244

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Fixes #671.

Kimi has no --mcp-config, so every Solenta-spawned kimi turn read the user-global ~/.kimi-code/: one mcp.json holding every project's MCP servers, and a workspaces.json listing every directory the CLI had ever opened. A run in project A could reach project B's threads, memory and tree.

Fixed in three layers, so the scope is enforced by the servers rather than by model discipline.

Per-run KIMI_CODE_HOME overlay — materializeKimiHome (electron/kimi.js), wired at electron/runner.js:4010. Copies config.toml, symlinks credentials/oauth/sessions/cache so login and -S resume still work, then writes a fresh mcp.json containing only Solenta's servers and a workspaces.json containing only this run's cwd. AGENTS.md and workspace-trust are never copied. Skipped for ssh/WSL projects (the overlay lives on this host) and when userDataPath is unset; a failed overlay is non-fatal and the turn proceeds. Side benefit: the config.toml effort-flip race is now local to the overlay instead of global.

Bound MCP sessions — the per-run mcp.json appends ?project= / ?projectId= to the server URLs. memory-server (buildServer({ bindProject })) forces every tool to that project and rejects a claimed different one; orchServer treats the bound id as proof of caller identity, outranking whatever the tool args claim, and thread_status now runs the same-project check it was missing.

threads_list is now project-scoped — it requires a projectId and returns only that project's threads. It previously returned every thread in every project, which is exactly how an agent picked another project's thread by title. Note this applies to all providers, not just kimi: a threads_list() call with no args is now an error.

Tests: new electron/test/kimi-home.test.js (overlay contents, symlinks, no AGENTS.md, mcp/workspace isolation), plus orch-server binding cases and memory-server scoping cases. Verified green in the worktree — kimi-home/orch-server/kimi/kimi-effort 90 pass 0 fail, test:memory 205 pass 0 fail.

Of the 857 changed lines, 453 are tests; the production diff is roughly 400 across 5 files.

Known follow-up, not addressed here: kimi-homes/<threadId> dirs are never reclaimed. They are tiny (symlinks plus three small files) but accumulate one per thread.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

…-issue-with-cross-contami-d6e244

# Conflicts:
#	electron/runner.js
@currentbits
currentbits merged commit 309f9ba into main Aug 22, 2026
5 of 6 checks passed
@currentbits
currentbits deleted the coder/fork-we-have-an-issue-with-cross-contami-d6e244 branch October 3, 2026 16:07
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.

Isolate Kimi runs: no cross-project threads, memory, or workspaces

1 participant