openclaw - ✅(Solved) Fix 工具调用参数解析失败: kimi-coding/k2p5 模型工具参数为空对象 [3 pull requests, 2 comments, 3 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#54366Fetched 2026-04-08 01:28:31
View on GitHub
Comments
2
Participants
3
Timeline
9
Reactions
1
Author
Timeline (top)
cross-referenced ×4referenced ×3commented ×2

PR fix notes

PR #54448: fix: preserve Kimi tool call arguments instead of clearing valid JSON

Description (problem / solution / changelog)

Summary

Fixes three related bugs in the Kimi (kimi-coding/k2p5) tool call argument repair pipeline that cause tool calls to fail with empty or undefined arguments:

  • tryParseMalformedToolCallArguments treats valid JSON as unfixable: When accumulated streaming JSON is already valid, JSON.parse(raw) succeeds but the function returns undefined — the same signal as "unrepairable". The caller then clears arguments, wiping correct tool parameters.
  • clearToolCallArgumentsInMessage assigns {} instead of undefined: The empty object pollutes shared references. Downstream validators see a present-but-empty object and report must have required property 'command' instead of recognizing arguments as absent.
  • else branch in wrapStreamRepairMalformedToolCallArguments unconditionally clears arguments: When repair returns undefined, arguments may already be correctly set via content_block_start.input (Kimi's non-incremental streaming path). Clearing here wipes them. The fix lets content_block_stop handle final argument resolution.

Root cause

Kimi k2p5 has two streaming behaviors:

  1. Incremental: content_block_start with input: {}, then input_json_delta events build up arguments
  2. Non-incremental: content_block_start with full input: {path: "..."}, no input_json_delta at all

The repair wrapper assumed path 1 exclusively. In path 2, partialJson stays empty, tryParseMalformedToolCallArguments("") returns undefined, and the else branch wiped the already-correct arguments.

Changes

FileChange
attempt.tstryParseMalformedToolCallArguments: return parsed args when JSON is valid
attempt.tsRemove clearToolCallArgumentsInMessage (no longer called)
attempt.tsRemove clear calls from the else branch in the stream wrapper
attempt.test.tsUpdate existing test + add 2 new tests covering the fix

Reproduction

With kimi-coding/k2p5:

# Before fix:
Validation failed for tool "exec":
  - command: must have required property 'command'
Received arguments: {}

# Or:
read tool called without path: toolCallId=tool_xxx argsType=undefined

Note on remaining pi-ai issues

Two additional Kimi tool call bugs exist in the upstream @mariozechner/pi-ai package (not addressed here):

  • content_block_stop overwrites block.arguments with parseStreamingJson(""){} even when partialJson is empty
  • A "Kimi API bug workaround" in content_block_start converts input: {} to undefined

These require a separate fix in pi-ai. This PR addresses all bugs within OpenClaw's own codebase.

Test plan

  • All 95 existing tests in attempt.test.ts pass
  • New test: valid JSON arguments are preserved through the repair pipeline
  • New test: arguments set by content_block_start.input survive incomplete delta attempts
  • Updated test: trailing suffix growing too long preserves last valid repair instead of wiping
  • TypeScript type check passes (pnpm tsgo)
  • Full lint/format check passes (pnpm check)
  • Manual verification with kimi-coding/k2p5 on Telegram

Fixes #54442 Fixes #53747 Refs #54366

🤖 Generated with Claude Code

Changed files

  • src/agents/pi-embedded-runner/run/attempt.test.ts (modified, +93/-2)
  • src/agents/pi-embedded-runner/run/attempt.ts (modified, +13/-23)

PR #56697: fix(tools): include parameter examples in validation errors to help models self-correct

Description (problem / solution / changelog)

Summary

Include tool-specific parameter examples in validation error messages so models can self-correct on retry.

Problem

Models like Kimi k2p5 intermittently send empty objects ({}) instead of required tool parameters. The current error message says:

Missing required parameter: path alias. Supply correct parameters before retrying.

This is too vague — the model retries with the same empty payload, creating a loop of 5+ failed attempts.

Fix

Add a TOOL_PARAM_EXAMPLES map for read/write/edit tools. When parameter validation fails, the error now includes a concrete example:

Missing required parameter: path alias. Supply correct parameters before retrying. Example: read({"path": "/absolute/path/to/file"})

This gives the model a template to follow on the next attempt, significantly improving self-correction rates for models with weak tool-call formatting.

One-file change, 14 lines added, 4 modified. No behavior change for well-formed tool calls.

Test plan

  • Change is additive — parameterValidationError gains an optional second parameter with no default behavior change
  • Existing tool param tests unaffected (validated locally)
  • Manual verification: Kimi k2p5 self-corrects faster with example in error response

Fixes #56376 Related: #55005, #55039, #53747, #54366

Changed files

  • src/agents/pi-tools.params.ts (modified, +14/-4)

PR #57716: Agents/tools: fix empty required array bug in tool schema alias handling

Description (problem / solution / changelog)

AI-Assisted

  • This PR was created with assistance from Claude
  • Testing: Unit tests updated and passing (25/26), scoped tests validate the fix
  • I understand the code changes and have verified they work correctly

Summary

Fixes #44203, #37645, #57551, #55528, #54975, #54366

This PR fixes a critical bug where tool schema required arrays were being incorrectly emptied when a dding parameter aliases (e.g., file_path as alias for path). The addClaudeParamAliasesToSchema f unction was removing original parameter names from required without preserving them, causing LLMs to receive schemas with no required parameters.

Changelog Entry

  • Agents/tools: fix empty required array bug in tool schema alias handling. Fixes #44203, #37645.

Problem

The addClaudeParamAliasesToSchema function was removing original parameter names (like path, oldT ext, newText) from the required array but not adding their aliases (like file_path, old_string , new_string). This caused:

  1. LLMs received schemas with empty or incomplete required arrays
  2. Models didn't know which parameters were actually required
  3. Tool calls failed validation with "Missing required parameters" errors
  4. Users experienced 100% failure rate for edit tool and other file operations

Related Issues

This bug has been reported multiple times with various symptoms:

  • #44203 - Original bug report: Edit tool fails with "Missing required parameters"
  • #37645 - Root cause analysis: patchToolSchemaForClaudeCompatibility empties required[] with ex act fix suggestion
  • #57551 - Kimi infinite retry loop consuming tokens due to repeated validation failures
  • #55528 - Write tool content parameter validation failure
  • #54975 - All tools receive empty {} arguments (closed but same root cause)
  • #54366 - kimi-coding/k2p5 model tool parameters empty object

Error Messages Users See

[tools] edit failed: Missing required parameters: path alias, oldText alias, newText alias. Supply cor rect parameters before retrying. [tools] read failed: Missing required parameter: path alias. Supply c orrect parameters before retrying.

Solution

  1. Preserve canonical keys in required array: The addClaudeParamAliasesToSchema function no lo nger modifies the required array. Original parameter names (e.g., path) remain in required, whil e aliases (e.g., file_path) are only added to properties.

  2. Add optional flag to RequiredParamGroup: Allows marking parameter groups as optional for ru ntime validation, supporting edit tool's dual-mode operation (single replacement vs. multi-replacement ).

  3. Cross-field validation for edit tool: Added explicit validation to ensure edit tool receives ei ther edits array or both oldText and newText.

Changes

  • src/agents/pi-tools.params.ts:

    • Add optional field to RequiredParamGroup type
    • Mark oldText/newText as optional in CLAUDE_PARAM_GROUPS.edit
    • Stop modifying required array in addClaudeParamAliasesToSchema
    • Update assertRequiredParams to skip optional groups
    • Add cross-field validation for edit tool
  • src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping .test.ts:

    • Update test assertion to verify path remains in required

Changed files

  • src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping.test.ts (modified, +3/-1)
  • src/agents/pi-tools.params.ts (modified, +45/-8)

Code Example

read tool called without path: toolCallId=xxx argsType=object
read failed: Missing required parameter: path (path or file_path)
RAW_BUFFERClick to expand / collapse

描述 kimi-coding/k2p5 模型通过 webchat 路由到 kimi-agent 时,工具调用全部失败,报 "missing required property"。

环境

  • OpenClaw 版本: (latest)
  • 模型: kimi-coding/k2p5
  • 渠道: webchat
  • 复现路径: webchat → kimi-agent → 工具调用(exec/read/edit 等)

日志

read tool called without path: toolCallId=xxx argsType=object
read failed: Missing required parameter: path (path or file_path)

变通方案 切换到 MiniMax M2.7 或其他模型后工具调用恢复正常

备注

  • 昨天同一配置可正常work,今天失败
  • 可能是模型生成的 tool_call 参数格式问题

extent analysis

Fix Plan

The fix involves modifying the kimi-coding/k2p5 model to include the required path parameter in the tool_call arguments.

Code Changes

To resolve the issue, update the tool_call function in the kimi-coding/k2p5 model to include the path parameter:

def tool_call(args):
    # Ensure the path parameter is included in the args
    if 'path' not in args and 'file_path' not in args:
        args['path'] = ''  # Default path if not provided
    # Rest of the function remains the same

Alternatively, you can also modify the webchat route to include the path parameter in the tool_call arguments:

def webchat_route(request):
    # ...
    tool_call_args = {'argsType': 'object', 'path': request.path}
    # ...

Verification

To verify the fix, test the webchat route with the updated kimi-coding/k2p5 model and check the logs for any errors. The read tool should now be called with the required path parameter.

Extra Tips

  • Ensure that the path parameter is properly validated and sanitized to prevent any potential security vulnerabilities.
  • Consider adding additional logging to track any issues with the tool_call function and its arguments.

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