Skip to content

Agents: add Claude Code parameter aliasing for read/write/edit tools - #768

Merged
steipete merged 2 commits into
openclaw:mainfrom
hsrvc:fix/tool-param-aliasing
Jan 12, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
hsrvc:fix/tool-param-aliasing

Conversation

@hsrvc

@hsrvc hsrvc commented Jan 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Models trained on Claude Code conventions (like Claude Sonnet/Opus) sometimes use different parameter names than pi-coding-agent expects:

Claude Code pi-coding-agent
file_path path
old_string oldText
new_string newText

When this happens, the model gets stuck in a loop trying variations of incorrect parameters until the agent times out (default 10 minutes). The model often self-reports this with messages like "抱歉,我在工具參數上卡住了" (Sorry, I got stuck on tool parameters).

This PR adds parameter aliasing to automatically translate Claude Code conventions to pi-coding-agent conventions for the read, write, and edit tools.

Changes

  • Add normalizeToolParams() function to translate parameter names
  • Add wrapToolParamNormalization() wrapper for tools
  • Apply normalization to read, write, and edit tools (both sandboxed and non-sandboxed)

Test plan

  • Existing pi-tools tests pass
  • Build succeeds
  • Manual testing with Claude Sonnet using Claude Code conventions (e.g., file_path instead of path)

@steipete steipete self-assigned this Jan 12, 2026
@steipete

Copy link
Copy Markdown
Contributor

good call!

@steipete

Copy link
Copy Markdown
Contributor
  • HIGH: Sandbox guard bypass with file_path. wrapSandboxPathGuard checks
    args.path before normalization; new aliasing happens inside tool execute.
    If model sends file_path, assertSandboxPath never runs for read/write/
    edit. src/agents/pi-tools.ts:413, src/agents/pi-tools.ts:430, src/agents/
    pi-tools.ts:435. Fix: normalize inside wrapSandboxPathGuard (use
    normalized args for guard + execute), or move guard to wrap normalized
    args.
    • MED: Missing regression tests for aliasing + sandbox guard. Add coverage
      in src/agents/pi-tools.test.ts for file_path→path and ensure sandbox
      guard triggers.

@steipete

Copy link
Copy Markdown
Contributor

taking over

@steipete
steipete force-pushed the fix/tool-param-aliasing branch from 4249798 to 6711eaf Compare January 12, 2026 08:54
@steipete
steipete merged commit 6a7b812 into openclaw:main Jan 12, 2026
@steipete

Copy link
Copy Markdown
Contributor

Landed via temp rebase onto main.\n\n- Gate: pnpm lint && pnpm build && pnpm test\n- Land commit: 6711eaf\n- Merge commit: 6a7b812\n\nThanks @hsrvc!

victorarias pushed a commit to victorarias/clawdbot that referenced this pull request Jan 13, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
Agents: add Claude Code parameter aliasing for read/write/edit tools
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
Agents: add Claude Code parameter aliasing for read/write/edit tools
zeekay pushed a commit to Dream-AI-4444/bot that referenced this pull request Sep 11, 2026
zeekay pushed a commit to Dream-AI-4444/clawdbot that referenced this pull request Sep 11, 2026
Agents: add Claude Code parameter aliasing for read/write/edit tools
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
Agents: add Claude Code parameter aliasing for read/write/edit tools
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants