Skip to content

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

Description

@proccl

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions