Kimi CLI is dead. You guys destroyed it.
What version of Kimi CLI is running?
0.78
Which open platform/subscription were you using?
null
Which model were you using?
null
What platform is your computer?
Arch Linux
What issue are you seeing?
Performance Regression Analysis: Kimi CLI v0.75 vs v0.78
Overview
This document analyzes the performance regression reported between Kimi CLI v0.75 (working) and v0.78 (broken). The user reports that v0.78 fills context 100% instantly, gets stuck in infinite loops reading files/executing commands, and performs significantly worse than v0.75.
Root Cause: FlowRunner Implementation Issues
The major architectural change in v0.77-0.78 was replacing the Ralph Loop with a Prompt Flow-based implementation. This introduced several critical bugs.
Bug #1: Context Filling Instantly (Critical)
Location: src/kimi_cli/soul/kimisoul.py - FlowRunner._flow_turn() method
Code in v0.78:
@staticmethod
async def _flow_turn(
soul: KimiSoul,
prompt: str | list[ContentPart],
) -> TurnOutcome:
wire_send(TurnBegin(user_input=prompt))
return await soul._turn(Message(role="user", content=prompt)) # type: ignore[reportPrivateUsage]
Problem: Each call to _flow_turn() creates a new Message object and passes it to soul._turn(). The _turn() method then appends this message to the context:
async def _turn(self, user_message: Message) -> TurnOutcome:
# ...
await self._checkpoint()
await self._context.append_message(user_message) # <-- Appends to context
logger.debug("Appended user message to context")
return await self._agent_loop()
Impact: Every iteration of the Ralph Loop adds a new user message to the context, causing it to fill up instantly.
Comparison with v0.75:
- v0.75 reused the same
user_messageobject and appended a system message to its content - v0.78 creates a new
Messageobject on every iteration
Fix:
@staticmethod
async def _flow_turn(
soul: KimiSoul,
prompt: str | list[ContentPart],
user_message: Message, # Pass the original user message
) -> TurnOutcome:
wire_send(TurnBegin(user_input=prompt))
return await soul._turn(user_message) # Reuse the same message object
Bug #2: Infinite Loop with 1 Quadrillion Max Moves (Critical)
Location: src/kimi_cli/soul/kimisoul.py - FlowRunner.ralph_loop() method
Code in v0.78 (lines 551-553):
total_runs = max_ralph_iterations + 1
if max_ralph_iterations < 0:
total_runs = 1000000000000000 # effectively infinite
Problem: When max_ralph_iterations < 0, total_runs is set to 1000000000000000 (1 quadrillion), which is effectively infinite. This causes the agent to run for an extremely long time.
Impact: The agent runs indefinitely, causing the context to fill up and potentially getting stuck in infinite loops.
Fix:
total_runs = max_ralph_iterations + 1
if max_ralph_iterations < 0:
total_runs = 1000 # More reasonable "infinite" limit
Bug #3: Missing Safeword Check (Important)
Location: src/kimi_cli/soul/kimisoul.py - FlowRunner.ralph_loop() method
Problem: The v0.75 Ralph Loop checked for <safeword>STOP</safeword> to stop the loop:
# v0.75 code (lines 233-234)
if result.final_message and RALPH_SAFEWORD in result.final_message.extract_text(" "):
return
This check is missing in the v0.78 FlowRunner implementation. The FlowRunner only checks for <choice>STOP</choice> in decision nodes, but the Ralph Loop in v0.75 used a different mechanism.
Impact: The agent cannot be stopped gracefully using the safeword mechanism.
Fix: Add safeword check in FlowRunner.run() or _execute_flow_node():
if result.final_message and RALPH_SAFEWORD in result.final_message.extract_text(" "):
return
Bug #4: Token Count Not Cumulative (Important)
Location: src/kimi_cli/soul/context.py - Context.update_token_count() method
Code in v0.78 (line 65):
async def update_token_count(self, token_count: int):
logger.debug("Updating token count in context: {token_count}", token_count=token_count)
self._token_count = token_count # <-- REPLACES instead of adds
Problem: The method replaces self._token_count instead of adding to it. This causes incorrect context usage calculations.
Impact: Incorrect context usage calculations, which affects compaction decisions. The context may appear to have fewer tokens than it actually does, or vice versa.
Fix:
async def update_token_count(self, token_count: int):
logger.debug("Updating token count in context: {token_count}", token_count=token_count)
self._token_count += token_count # Add instead of replace
Bug #5: FlowRunner Creates New Message Objects on Every Iteration (Performance)
Location: src/kimi_cli/soul/kimisoul.py - FlowRunner._flow_turn() method
Code in v0.78:
return await soul._turn(Message(role="user", content=prompt))
Problem: Creates a new Message object on every call, which is inefficient and causes unnecessary memory allocation.
Impact: Increased memory usage and CPU overhead.
Fix: Pass the original user message through the flow:
class FlowRunner:
def __init__(self, flow: PromptFlow, *, max_moves: int = DEFAULT_MAX_FLOW_MOVES, user_message: Message | None = None) -> None:
self._flow = flow
self._max_moves = max_moves
self._user_message = user_message
Bug #6: Nested Loop Infinite Retry (Potential Infinite Loop)
Location: src/kimi_cli/soul/kimisoul.py - FlowRunner._execute_flow_node() method
Code in v0.78 (lines 635-664):
while True:
result = await self._flow_turn(soul, prompt)
steps_used += result.step_count
if result.stop_reason == "tool_rejected":
logger.error("Prompt flow stopped after tool rejection.")
return None, steps_used
if node.kind != "decision":
return edges[0].dst, steps_used
choice = (
parse_choice(result.final_message.extract_text(" "))
if result.final_message
else None
)
next_id = self._match_flow_edge(edges, choice)
if next_id is not None:
return next_id, steps_used
# ... warning and retry logic ...
prompt = (
f"{base_prompt}\n\n"
"Your last response did not include a valid choice. "
"Reply with one of the choices using <choice>...</choice>."
)
Problem: If the LLM keeps returning invalid choices (not containing <choice>...</choice>), the inner while True loop will loop indefinitely.
Impact: Potential infinite loops when the LLM doesn't respond with a valid choice.
Fix: Add a max retry limit:
max_invalid_choices = 3
invalid_choice_count = 0
while True:
result = await self._flow_turn(soul, prompt)
steps_used += result.step_count
if result.stop_reason == "tool_rejected":
logger.error("Prompt flow stopped after tool rejection.")
return None, steps_used
if node.kind != "decision":
return edges[0].dst, steps_used
choice = (
parse_choice(result.final_message.extract_text(" "))
if result.final_message
else None
)
next_id = self._match_flow_edge(edges, choice)
if next_id is not None:
return next_id, steps_used
invalid_choice_count += 1
if invalid_choice_count >= max_invalid_choices:
logger.error("Too many invalid choices, stopping flow.")
return None, steps_used
# ... warning and retry logic ...
Summary of Critical Fixes
1. Fix Context Filling Instantly (Bug #1)
File: src/kimi_cli/soul/kimisoul.py
Method: FlowRunner._flow_turn() and FlowRunner.ralph_loop()
Change: Pass the original user message through the flow instead of creating a new one on each iteration.
2. Fix Infinite Loop with 1 Quadrillion Max Moves (Bug #2)
File: src/kimi_cli/soul/kimisoul.py
Method: FlowRunner.ralph_loop()
Change: Use a more reasonable default for "infinite" iterations (e.g., 1000 instead of 1 quadrillion).
3. Fix Token Count Not Cumulative (Bug #4)
File: src/kimi_cli/soul/context.py
Method: Context.update_token_count()
Change: Add to the existing token count instead of replacing it.
4. Add Safeword Check (Bug #3)
File: src/kimi_cli/soul/kimisoul.py
Method: FlowRunner.run() or FlowRunner._execute_flow_node()
Change: Add check for <safeword>STOP</safeword> to stop the loop gracefully.
5. Add Max Retry Limit for Invalid Choices (Bug #6)
File: src/kimi_cli/soul/kimisoul.py
Method: FlowRunner._execute_flow_node()
Change: Add a max retry limit (e.g., 3) for invalid choices to prevent infinite loops.
Testing Recommendations
- Test Context Growth: Run the agent with Ralph Loop enabled and verify that the context doesn't fill instantly.
- Test Infinite Loop Prevention: Run the agent with
max_ralph_iterations < 0and verify it stops after a reasonable number of iterations. - Test Safeword: Verify that the safeword
<safeword>STOP</safeword>stops the loop. - Test Token Count: Verify that the token count is cumulative and correctly reflects the context size.
- Test Invalid Choice Handling: Verify that the agent stops after a few invalid choices instead of looping indefinitely.
Additional Notes
- The v0.75 Ralph Loop implementation was simpler and more efficient than the v0.78 FlowRunner implementation.
- The FlowRunner adds unnecessary abstraction overhead for the Ralph Loop use case.
- Consider reverting to the v0.75 Ralph Loop implementation or significantly refactoring the FlowRunner for the Ralph Loop case.
What steps can reproduce the bug?
"upgrading" to new trash 0.78 verson
What is the expected behavior?
Kimi CLI 0.75 was amazing, it worked like a miracle. I have downgraded (I mean upgraded) to version 0.75 from 0.78 because the new version is so trash, so disgusting that i can't take it any more. the context fills to 100% instantly even if it just reads 2 files. The context management has gotten extremely horrible. The model which worked perfectly before now gets stuck in reading a single file or executing a single command over and over again, in a infinite loop. I can't believe that in just 2 illustration a miraculous tool can turn into total garbage/trash.
Additional information
Just revert everything to 0.75 and start over, or do nothing and loose, while other tools such as open code, claude code, gemini cli, openai codex, qwen code, cursor cli, amazon Q cli win and Kimi cli turns into trash forever and never recovers and slowly but surely scrapped away as it will be become (already has become) a waste of money and time.
Plus points for the moon 🌘🌓🌔 spinning more and intentionally delaying response for no reason what so ever in new 0.78 version compared to instant response in version 0.75 also the auto-compact is making broken summaries in the new 0.78 version, auto compact in version 0.75 made accurate summaries unlike 0.78 losing coherence and turning the output into something no one asked for.
Can we get a branch with FlowRunner reverted so the community can verify the regression?
Can we get a branch with FlowRunner reverted so the community can verify the regression?
You can choose model version 0.75 if this model is stable for you.
Can we get a branch with FlowRunner reverted so the community can verify the regression?
You can choose model version 0.75 if this model is stable for you.
I’m staying on 0.75 permanently because 0.78 destroyed the workflow I built my productivity around. The six patches above restore that stability. If the project won’t verify a 1-commit revert, please update the README to say “CLI stability is no longer a priority” so the rest of us can stop waiting and migrate.
If you don't set --prompt-flow or --max-ralph-iterations options, 0.78 has no difference in terms of the agent loop from 0.75. Infinite loop of reading files is typically because of the model hallucinating behind the API you use and subject to the limit of max_steps_per_turn config item (defaults to 100).
Did you somehow enabled max_ralph_iterations in your config? (Even with this there shouldn't be infinite loop during one turn.)
Please provide more info if you can reproduce this with Kimi K2 (or other stable) model. We thank you for the feedback!
If you don't set
--prompt-flowor--max-ralph-iterationsoptions, 0.78 has no difference in terms of the agent loop from 0.75. Infinite loop of reading files is typically because of the model hallucinating behind the API you use and subject to the limit ofmax_steps_per_turnconfig item (defaults to 100).Did you somehow enabled
max_ralph_iterationsin your config? (Even with this there shouldn't be infinite loop during one turn.)Please provide more info if you can reproduce this with Kimi K2 (or other stable) model. We thank you for the feedback!
I am using deepseek 3.2 model which is a very capable model, please stop using microsoft prompt flow, ralph was much better, until then i am switching to claude code! have a good one.