#22419: Add filterReasoningContent config option for Xiaomi Mimo v2 flash
agents
size: S
Cluster:
Model Reasoning Fixes
## Problem
Xiaomi Mimo v2 flash model returns an annoying `reasoning_content` field in responses when in thinking mode:
```json
"reasoning_content": "Okay, the user just asked me to introduce myself. That is a pretty straightforward request..."
```
This content appears unnatural and clutters responses.
## Solution
This PR adds a new config option `filterReasoningContent` that strips `reasoning_content` from model responses when enabled.
### Usage
Add to your `~/.openclaw/openclaw.json`:
```json
{
"agents": {
"defaults": {
"filterReasoningContent": true
}
}
}
```
### Changes
1. **`src/config/types.agent-defaults.ts`** - Added `filterReasoningContent?: boolean` to `AgentDefaultsConfig`
2. **`src/agents/pi-embedded-utils.ts`** - Added `stripReasoningContent()` function and updated `extractAssistantText()`
3. **`src/agents/pi-embedded-subscribe.handlers.messages.ts`** - Wired up config option
4. **`src/agents/tools/sessions-helpers.ts`** - Updated helper to support filtering
The default is `false` to maintain backward compatibility.
## Testing
Tested locally with the Xiaomi Mimo v2 flash model. When `filterReasoningContent: true`, the reasoning content is properly filtered from responses.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Added `filterReasoningContent` config option to strip `reasoning_content` fields from Xiaomi Mimo v2 flash model responses
**Key changes:**
- Added boolean config field `filterReasoningContent` to `AgentDefaultsConfig` (defaults to `false`)
- Implemented `stripReasoningContent()` function using regex pattern to remove JSON `reasoning_content` fields
- Wired up filtering in `extractAssistantText()` functions across message handlers and session helpers
- Filtering applies during text sanitization pipeline alongside existing filters for thinking tags and tool calls
**Issue found:**
- Regex pattern for stripping `reasoning_content` uses `[^"']*` which won't handle escaped quotes correctly - will fail if reasoning content contains `\"escaped\"` quotes within the string value
<h3>Confidence Score: 3/5</h3>
- Safe to merge with one logical issue that may cause problems if reasoning content contains escaped quotes
- Implementation is straightforward and maintains backward compatibility with default `false`. However, the regex pattern has a clear bug that will fail to correctly strip `reasoning_content` if the value contains escaped quotes. Whether this is critical depends on whether Xiaomi actually returns such content - if reasoning text is always simple prose without quotes, it may work fine in practice.
- Pay attention to `src/agents/pi-embedded-utils.ts` line 223 - the regex pattern needs review
<sub>Last reviewed commit: 2ffd5a4</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#17304: feat(gemini): robust handling for non-XML reasoning headers (`Think...
by YoshiaKefasu · 2026-02-15
74.0%
#6559: Fix LiteLLM reasoning-tag handling + fallback to <think> content
by Najia-afk · 2026-02-01
72.0%
#7987: feat: Support iflow/GLM-4.6 reasoning_content and tokens
by EisonMe · 2026-02-03
70.9%
#23462: fix: extract thinking blocks as fallback in extractTextFromChatContent
by nszhsl · 2026-02-22
70.3%
#13235: feat: stream reasoning_content via /v1/chat/completions SSE
by mode80 · 2026-02-10
69.9%
#6730: feat: Make OpenAI Codex CLI models usable - reasoning effort directive
by levineam · 2026-02-02
69.7%
#10430: fix: remove Minimax from isReasoningTagProvider
by echoedinvoker · 2026-02-06
69.7%
#17455: fix: strip content before orphan closing think tags
by jwt625 · 2026-02-15
69.6%
#11010: fix(control-ui): hide tool call cards when thinking toggle is off
by Annaxiebot · 2026-02-07
68.9%
#5947: Feature/kimi reasoning support
by zzjj7000 · 2026-02-01
68.6%