MoonshotAI / MoonshotAI/kimi-cli

Feature Request: expose runtime identity (pid + session id) for external observers

Open
#2,116 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
11.4k
Forks
1.3k
Avg merge
9h 47m
Merged PRs (30d)
2

Description

What feature would you like to see?

Today, third-party IDE plugins and agent session-management tools cannot tell whether a given Kimi session is currently being served by a running kimi-cli process. That's the blocker.

The information they need is the simple (session_id → live PID?) mapping. Without it, integrations can't:

  • show session X is live, attach versus session X is idle, resume indicators
  • route an IDE action (open file, run task, fetch context) to the right kimi process when several are running on different sessions
  • detect orphaned sessions to surface crash-recovery prompts
  • enumerate "all kimi sessions live on this machine right now"
  • aggregate per-session resource use (per-PID CPU / memory mapped back to a session id) for billing or audit

Today this is unanswerable from kimi-cli's outside surface:

  • The OS process title is a static Kimi Code for every interactive process.
  • A fresh session created without --session / --resume does not carry its session id in argv.
  • No PID / lockfile / status file is written under the session directory for the interactive session.

Neighbouring CLIs already solve this:

  • Copilot CLI writes a lockfile-with-PID under its share directory.
  • Claude Code auto-injects --resume <session-id> into argv so even ps aux recovers the mapping.

Kimi is the missing piece in the multi-agent CLI ecosystem.

Proposed solution

Write a small JSON sidecar at <session_dir>/runtime.json whenever _run() establishes an interactive session, containing:

{schema_version, pid, session_id, work_dir, hostname, started_at, kimi_version}

  • Atomic write via the existing utils.io.atomic_json_write helper.
  • Schema-versioned so external readers can ignore unrecognised future versions.
  • UTF-8 throughout, so non-ASCII paths and session ids round-trip.
  • Cleared only on cross-session Reload (/new / /fork / /undo — same PID switching to a different session id). All other exit paths leave the file as-is; consumers verify PID liveness, so a stale claim becomes "session not currently reachable" rather than a false positive.

Consumers scan <session_dir>s under ~/.kimi/sessions/, read the file, verify the recorded PID is alive — and now they have the (session_id → live PID?) answer they need.

Additional information

Implementation in PR #2082.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The proposed runtime sidecar belongs in the interactive session setup in _run(), using utils.io.atomic_json_write and the session directories under ~/.kimi/sessions/. Read PR #2082 first, then verify the runtime.json fields, cross-session Reload behavior, UTF-8 handling, and atomic-write coverage; done means external readers can map a live PID to its session id without false positives.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.