03. 核心模块对比:Crush vs Kimi Code CLI
3.1 Agent/Session/Message 三层模型
Crush 核心模型
Coordinator (协调 Agent、Session、Message、Tools)
↓
SessionAgent → Session → Message
Kimi Code CLI 核心模型
KimiCLI (编排 Runtime、Soul、Agent、Session)
↓
KimiSoul → Context → Message
3.2 Agent 实现对比
Crush: SessionAgent (Go)
type SessionAgent interface {
Run(context.Context, SessionAgentCall) (*fantasy.AgentResult, error)
SetModels(large Model, small Model)
SetTools(tools []fantasy.AgentTool)
SetSystemPrompt(systemPrompt string)
Cancel(sessionID string)
Summarize(context.Context, string, fantasy.ProviderOptions) error
}
Kimi Code CLI: KimiSoul (Python)
class KimiSoul:
async def run(self, user_input: str | list[ContentPart]):
await self._turn(user_input)
async def _agent_loop(self) -> TurnOutcome:
while True:
if self._context.token_count >= limit:
await self.compact_context()
step_outcome = await self._step()
3.3 Session/Context 对比
3.4 Tool 基础结构对比
Crush: fantasy.AgentTool
func NewBashTool(permissions, workingDir, shell, cfg) fantasy.AgentTool {
return fantasy.NewAgentTool("bash", description,
func(ctx context.Context, params BashParams) (ToolResponse, error) {
return executeBash(ctx, params)
})
}
Kimi Code CLI: CallableTool2
class Shell(CallableTool2[Params]):
name: str = "Shell"
params: type[Params] = Params
async def __call__(self, params: Params) -> ToolReturnValue:
if not await self._approval.request(...):
return ToolRejectedError()
return ToolOk(output=result.stdout)
3.5 Runtime/Coordinator 对比