← Back to PRs

#5947: Feature/kimi reasoning support

by zzjj7000 open 2026-02-01 04:22 View on GitHub →
agents
Summary This PR addresses visibility issues with the Moonshot Kimi K2 Thinking model and enhances configuration flexibility. Changes - Enable Reasoning: Sets `reasoning: true` for the `kimi-k2-thinking` model. This allows OpenClaw to correctly parse and display the `<thinking>` blocks, preventing the "invisible output" issue where the UI would hide the response. - Flexible API URL: Adds support for `MOONSHOT_BASE_URL` and `MOONSHOT_API_URL` environment variables. This allows users to configure custom endpoints (e.g., proxies or regional `.cn` endpoints) without modifying source code, while keeping the default upstream URL (`api.moonshot.ai`). <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds Moonshot configuration updates (allowing `MOONSHOT_BASE_URL`/`MOONSHOT_API_URL` and adding a `kimi-k2-thinking` model entry with `reasoning: true`). However, the changeset also includes several large, unrelated behavioral additions: a SmartRouter that can dynamically switch models at runtime and changes rate-limit failover behavior, a new context-optimizer feature that makes Gemini cachedContents API calls, a PatchManager plus local patch tooling/artifacts, plus a new `package-lock.json` and Windows batch scripts with a hard-coded local path. These extra changes significantly expand scope and risk; they should be split into separate PRs or removed so this PR remains focused on Moonshot reasoning/base URL. <h3>Confidence Score: 1/5</h3> - This PR is not safe to merge as-is due to significant out-of-scope behavioral changes and new external API-calling logic. - While the Moonshot reasoning/base URL change is small, the PR also introduces SmartRouter model switching, modifies failover behavior, adds a context optimizer that performs external Gemini API calls and passes undocumented options, and commits multiple local/dev artifacts (package-lock, patch files, hard-coded .bat scripts). These changes create substantial risk of regressions and maintenance burden. - src/agents/pi-embedded-runner/run.ts, src/features/context-optimizer/index.ts, scripts/run-node.mjs, package-lock.json, run_openclaw.bat, setup_wizard.bat, patches/*.patch, .gitattributes <!-- greptile_other_comments_section --> <sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs