Skip to content

fix(kimi): drop the per-cwd -c sentinel so kimi threads cannot resume each other's session (#220) - #350

Merged
currentbits merged 3 commits into
mainfrom
coder/kimi-threads-started-from-the-planboard--472d94
Aug 17, 2026
Merged

currentbits merged 3 commits into
mainfrom
coder/kimi-threads-started-from-the-planboard--472d94

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Fixes #220.

The reported symptom was not the reported cause

Issue #220 says a kimi thread started from the planboard "does not know the task", which points at the prompt never reaching the CLI. It does. Verified live against kimi 0.36.0: a fresh -p with a multiline GitHub issue body is delivered intact, and a brand-new thread has sessionId: null (services.js createThread, and setProvider clears it on a provider change), so its first turn emits no resume flag at all.

Actual root cause

-c is per-directory, not per-thread, and Solenta stamped sessionId: "cwd" after any kimi turn that produced no resume hint (electron/runner.js, capturedKimiSessionId || thread.sessionId || "cwd").

Every kimi thread without its own worktree runs in the same project folder, so:

  1. Thread A runs a turn, gets no resume hint, is stamped "cwd".
  2. Thread B runs in the same folder. kimi's "last session for this directory" is now B's.
  3. Thread A's next turn emits -c and resumes B's session. A's prompt arrives as a follow-up to a conversation about someone else's task, and the agent behaves as if it was handed nothing.

This is a second-turn-and-later bug, and it bleeds across threads. A first turn was never affected.

The fix

Drop the sentinel instead of guarding it. kimi emits real resume hints and -S <id> works, so the per-cwd continue is dead legacy — deleting it is a smaller diff than defending it.

  • electron/runner.js — a hint-less turn stores null, never "cwd"; an existing real session id is still preserved.
  • electron/providers.js — deleted the -c branch from kimi buildArgs; a leftover "cwd" is treated as no session rather than passed as -S cwd.
  • electron/store.js — load heals leftover "cwd" rows to null, so existing stores stop bleeding without a migration step.

An intermediate first-turn guard was written and then removed, so there is one defense here rather than three overlapping ones.

Verification

Regression test: thread A's second turn does not -c into a session only thread B created — a hint-less turn on A, then a real session id captured by B in the same project directory, then A's second turn must emit neither -c nor B's id.

Checked both directions rather than trusting a green run: 74 pass across kimi.test.js / store.test.js / providers.test.js on this branch, and reverting only the three source files (leaving the tests) fails 11. Full suites: electron 973/975, renderer 823/823. The two electron failures are pre-existing and unrelated — the known wireClient × webBridge reconnect baseline, and a workflow timing flake that passes when workflow.test.js is run alone.

Accepted trade-off

A hint-less older kimi can no longer continue a session across turns. Losing resume is a better failure than silently resuming a different thread's conversation.

Deliberately out of scope

Willem added 3 commits August 17, 2026 19:49
A fresh Start-task thread that already carries the legacy cwd session
sentinel was continuing some other kimi conversation in that directory,
so the issue prompt arrived as a follow-up and the agent acted like it
had no task. Skip -c until this thread has an assistant reply; -S still
resumes a real session id.
…er (#220)

-c continues the last session in the working directory, not this thread.
Two no-worktree kimi threads in the same project therefore bled: after a
hint-less turn stamped sessionId "cwd", the next -c resumed whoever last
ran in that folder. Stop inventing the sentinel, stop emitting -c, and
heal leftover "cwd" rows to null. Resume only via -S with a real id.
… kimi per-cwd -c sentinel let threads resume each other's session (#220)
@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.

@currentbits
currentbits merged commit 4224982 into main Aug 17, 2026
1 check failed
@currentbits
currentbits deleted the coder/kimi-threads-started-from-the-planboard--472d94 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.

Kimi threads started from the planboard do not know the task

1 participant