MoonshotAI / MoonshotAI/kimi-cli

Session becomes extremely slow in v1.37.0 after extensive MATLAB work

Open
#2,091 2 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

Bug Report: Session Becomes Extremely Slow in v1.37.0

Summary

After upgrading to kimi-cli v1.37.0, a specific session becomes extremely slow (several seconds per token, even loading animation is laggy), while other sessions and the CLI itself remain fast.

Environment

  • OS: Windows 10/11
  • kimi-cli version: 1.37.0 (upgraded from 1.30.0)
  • Python: 3.13.3
  • Model: kimi-code/kimi-for-coding

Problem Description

Symptoms
  • Token generation is extremely slow (several seconds per token)
  • Loading animation stutters/lags
  • Only affects one specific session; other sessions work fine
  • kimi --version responds instantly (not a system performance issue)
Session Details

The affected session was used for:

  • MATLAB development (7R robotic arm kinematics)
  • Bayesian optimization tasks
  • Multiple background MATLAB training jobs
Investigation Results

We performed extensive debugging:

  1. Context files: Cleaned from 66MB → 63KB (99.9% reduction)

    • Deleted all context_X.jsonl files
    • Cleared wire.jsonl
    • No improvement
  2. Task logs: Cleaned from ~60MB → 2MB (96% reduction)

    • Cleared huge output.log files (44MB, 10MB, 4MB)
    • No improvement
  3. Additional directories: Removed from state.json

    • Removed D:\Document\code\Matlab\7Rmatlab from additional_dirs
    • No improvement
  4. AGENTS.md files: Temporarily renamed 3 large AGENTS.md files in project

    • Total ~22KB of project documentation
    • No improvement
  5. Moved entire MATLAB directory: Eliminated any file scanning issues

    • No improvement
Key Finding: Encoding Corruption

In context.jsonl, we found encoding corruption:

{"role":"user","content":"���"}  // Should be "你好"

The file contains invalid UTF-8 sequences, suggesting encoding issues during session persistence.

Current Session State
  • context.jsonl: 109 lines, ~63KB
  • state.json: 1.5KB
  • wire.jsonl: ~23KB (cleared)
  • Tasks directory: ~2MB (cleaned)
  • Total: Well under normal limits

Reproduction Steps

  1. Create a session with extensive MATLAB/technical work
  2. Run multiple background tasks that generate large outputs
  3. Upgrade from v1.30.0 to v1.37.0
  4. Resume the session
  5. Observe extreme slowness in token generation

Expected Behavior

Session should remain responsive regardless of history, or provide tools to properly clean/reset session without losing core state.

Actual Behavior

Session becomes unusably slow despite all cleanup efforts.

Workaround

Downgrading to v1.30.0 resolves the issue (confirmed by user).

Additional Context

  • The session was working fine in v1.30.0
  • Only this specific session is affected; other sessions work normally
  • System resources are normal (CPU 13-19%, plenty of RAM)

Possible Causes

  1. v1.37.0 streaming/rendering changes: New version may have introduced performance regression with certain session states
  2. Encoding handling: Corrupted UTF-8 in context.jsonl may cause parsing overhead
  3. Background task scanning: Even with cleaned logs, task metadata scanning may be inefficient

Attachments

N/A (session contains sensitive project data)

Checklist

  • I have searched existing issues
  • I have provided detailed environment info
  • I have tested with a fresh session (works fine)
  • Downgrading resolves the issue

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

Start by reproducing the slowdown when resuming the affected session on v1.37.0, comparing it with v1.30.0 and a fresh session. Inspect the session artifacts named in the report—context.jsonl, state.json, wire.jsonl, and task logs—especially the corrupted UTF-8 entry, then identify whether cleanup or encoding state correlates with latency. Done means a reproducible cause and a responsive resumed session without losing core state.

Written by the indexing model from the issue text.

Assessment

Tech stack
matlab, python
Domain
cli, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.