#5947: Feature/kimi reasoning support
agents
Cluster:
Kimi Model Enhancements
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
#6454: fix: enable reasoning flag for Kimi K2.5 in Moonshot provider (#6451)
by coupclawbot · 2026-02-01
85.9%
#9024: Fix/Moonshot Provider Issue with kimi-k2-thinking Model Role Mappin...
by fotorpics · 2026-02-04
84.3%
#21911: Enable `reasoning: true` for Kimi models
by ighostych · 2026-02-20
83.6%
#4459: fix: enable image input for Kimi K2.5 and refresh stale config mode...
by manikv12 · 2026-01-30
80.8%
#6015: CLI: clarify Moonshot AI/Kimi auth option labels based on user feed...
by xxr3376 · 2026-02-01
80.5%
#6960: feat: Add kimi-coding provider support
by YYW0228 · 2026-02-02
78.7%
#22194: fix(agent) Moonshot/Kimi kimi-k2.5 returns ROLE_UNSPECIFIED
by ShengFuC · 2026-02-20
78.1%
#14187: fix: add Moonshot AI to non-standard provider detection
by shad0wca7 · 2026-02-11
76.0%
#7770: feat(routing): Smart Router V2 - Configuration-driven model dispatc...
by zzjj7000 · 2026-02-03
75.6%
#19281: fix: set supportsDeveloperRole false as default for moonshot provider
by MisterGuy420 · 2026-02-17
75.0%