openclaw - 💡(How to fix) Fix [Feature Request] Auto-remove spaces between Chinese and English characters in file paths [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#73941Fetched 2026-04-29 06:13:06
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
0
Timeline (top)
commented ×1

Fix Action

Fix / Workaround

Current workarounds

We use the following to mitigate:

  1. Python global patch (sitecustomize.py) - intercepts open(), os.path.* etc.
  2. Node.js middleware - intercepts tool call path parameters
  3. Symbolic link mapping - maps paths with spaces to correct paths without spaces
RAW_BUFFERClick to expand / collapse

Problem Description

When AI models (such as Qwen, PAI, MiniMax, etc.) output file paths, they automatically add spaces between Chinese and English characters.

Example

Expected path (actual directory name): Z:\G营销\AI临时文件\report.xlsx

Model output (incorrect): Z:\G 营销\AI 临时文件\report.xlsx

Impact

  1. File operations fail - open(), os.path.exists() etc. cannot find files
  2. Path validation fails - paths look correct but don't exist
  3. Cross-platform issues - Windows Chinese paths with spaces cause problems
  4. Poor user experience - paths shown to users cannot be used directly

Affected scenarios

  • Reports generated by agents saved to incorrect paths
  • File open requests from users with path resolution errors
  • Any file path containing mixed Chinese and English characters

Current workarounds

We use the following to mitigate:

  1. Python global patch (sitecustomize.py) - intercepts open(), os.path.* etc.
  2. Node.js middleware - intercepts tool call path parameters
  3. Symbolic link mapping - maps paths with spaces to correct paths without spaces

But these are all temporary solutions and don't cover all scenarios (PowerShell commands, network share access, etc.).


Suggested Solution

Recommended: Path Auto-Fix Middleware

Add path auto-fix mechanism at the OpenClaw layer:

ypescript // Example pseudocode function fixPath(path: string): string { // Remove spaces between Chinese and English characters return path .replace(/([A-Za-z0-9_])\s+([\u4e00-\u9fff])/g, '\\') .replace(/([\u4e00-\u9fff])\s+([A-Za-z0-9_])/g, '\\'); }

Advantages:

  • Single fix point, covers all tool calls
  • Configurable and can be disabled
  • Independent of specific models

Alternative: Model Prompt Optimization

Add path format guidelines in system prompts:

` Note: Do not add spaces between Chinese and English characters in paths. For example:

  • ✅ Z:\G营销\AI临时File
  • ❌ Z:\G 营销\AI 临时File `

Disadvantage: Depends on model following instructions, not reliable enough


Environment

  • OpenClaw version: Latest
  • Operating system: Windows
  • Models: PAI Qwen / MiniMax etc.

Additional Context

This is a common issue when AI models generate file paths. The same problem exists in many AI coding assistants. A built-in path normalization feature in OpenClaw would solve this comprehensively.

extent analysis

TL;DR

Implement a path auto-fix mechanism at the OpenClaw layer to remove spaces between Chinese and English characters in file paths.

Guidance

  • Identify all instances where AI models generate file paths and apply the path auto-fix mechanism to ensure consistency.
  • Verify the fix by testing file operations, path validation, and cross-platform compatibility with the updated paths.
  • Consider implementing the path auto-fix mechanism as a configurable middleware to allow for easy enabling or disabling.
  • Review the current workarounds (Python global patch, Node.js middleware, symbolic link mapping) and assess whether they can be replaced or augmented by the new path auto-fix mechanism.

Example

function fixPath(path: string): string {
  // Remove spaces between Chinese and English characters
  return path
   .replace(/([A-Za-z0-9_])\s+([\u4e00-\u9fff])/g, '$1$2')
   .replace(/([\u4e00-\u9fff])\s+([A-Za-z0-9_])/g, '$1$2');
}

Notes

The provided solution focuses on the OpenClaw layer, but it's essential to consider the broader ecosystem, including other AI models and potential interactions with different operating systems.

Recommendation

Apply the path auto-fix middleware, as it offers a single fix point, is configurable, and can be disabled if needed, making it a more reliable and comprehensive solution than model prompt optimization.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Feature Request] Auto-remove spaces between Chinese and English characters in file paths [1 comments, 2 participants]