openclaw - ✅(Solved) Fix Regression: Kimi Coding (official Anthropic-compatible endpoint) emits malformed read tool calls on current OpenClaw builds [3 pull requests, 2 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#53747Fetched 2026-04-08 01:23:59
View on GitHub
Comments
2
Participants
2
Timeline
11
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×4referenced ×3commented ×2closed ×1

Root Cause

So exec is not the root cause. It only often appears in failing sessions because the agent is doing multi-step tool planning.

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 #59440: fix: normalize Kimi anthropic tool payloads

Description (problem / solution / changelog)

Summary

  • mark Kimi and Kimi Coding as OpenAI-function-style Anthropic tool payload providers
  • align the bundled plugin capability metadata with the fallback capability registry
  • add regression coverage for Kimi payload normalization on the Anthropic Messages path

Fixes #59327 Fixes #54442 Fixes #58817 Fixes #53747 Fixes #56916

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • extensions/kimi-coding/index.ts (modified, +2/-0)
  • src/agents/pi-embedded-runner-extraparams.test.ts (modified, +71/-8)
  • src/agents/provider-capabilities.test.ts (modified, +13/-6)
  • src/agents/provider-capabilities.ts (modified, +2/-0)

Code Example

{
  "baseUrl": "https://api.kimi.com/coding/",
  "api": "anthropic-messages",
  "models": [{ "id": "k2p5" }]
}

---

[agent/embedded] read tool called without path: toolCallId=... argsType=object
[tools] read failed: Missing required parameter: path (path or file_path). Supply correct parameters before retrying.

---

acp_agent:main:main_1773151117097

---

embedded run start ... provider=kimi-coding model=k2p5
embedded run tool start ... tool=exec
embedded run tool end ... tool=exec
embedded run tool start ... tool=exec
embedded run tool end ... tool=exec
read tool called without path ... argsType=object
embedded run tool start ... tool=read

---

acp_agent:main:main_1773225025043

---

embedded run start ... provider=kimi-coding model=k2p5
read tool called without path ...
embedded run tool start ... tool=read
...
embedded run tool start ... tool=exec
embedded run tool end ... tool=exec
RAW_BUFFERClick to expand / collapse

Summary

Kimi Coding via the official Kimi Code Anthropic-compatible endpoint started producing malformed tool calls after upgrading OpenClaw. The most visible failure is repeated read calls with no path / file_path.

This looks like a fresh regression on current builds, not the old Moonshot Direct / OpenAI-compatible issue from #15809.

Current Environment

  • OpenClaw: 2026.3.23-1
  • Runtime seen in logs: Node 25.8.1
  • Provider: kimi-coding
  • Model configured in OpenClaw: k2p5
  • API mode: anthropic-messages
  • Base URL: https://api.kimi.com/coding/
  • Host OS: Linux

Important distinction

This is not using the old api.moonshot.ai OpenAI-compatible route. It is using the official Kimi Code endpoint documented here: Use in Third-Party Coding Agents

In my OpenClaw config the provider is configured roughly as:

{
  "baseUrl": "https://api.kimi.com/coding/",
  "api": "anthropic-messages",
  "models": [{ "id": "k2p5" }]
}

Symptoms

OpenClaw logs repeatedly show malformed read tool calls:

[agent/embedded] read tool called without path: toolCallId=... argsType=object
[tools] read failed: Missing required parameter: path (path or file_path). Supply correct parameters before retrying.

This happens many times on current builds.

What I verified outside OpenClaw

Using the same Kimi Coding API key against the same official Anthropic-compatible endpoint, direct API calls succeed:

  • POST https://api.kimi.com/coding/v1/messages
  • headers: x-api-key, anthropic-version: 2023-06-01
  • model: k2p5

Direct minimal tests produce valid tool payloads:

  • exec returns valid {"command":"pwd"} / {"command":"ls -la"}
  • read returns valid {"path":"package.json"} or {"file_path":"package.json"}

So this does not look like a Kimi endpoint incompatibility by itself. It looks like a regression in OpenClaw's runtime integration / prompting / tool orchestration for Kimi Coding on newer builds.

What I found in real OpenClaw logs

Case 1: exec succeeds, then later read loses path

Run ID:

acp_agent:main:main_1773151117097

Sequence from logs:

embedded run start ... provider=kimi-coding model=k2p5
embedded run tool start ... tool=exec
embedded run tool end ... tool=exec
embedded run tool start ... tool=exec
embedded run tool end ... tool=exec
read tool called without path ... argsType=object
embedded run tool start ... tool=read

So in this run, exec itself is fine, but the next read tool call is malformed.

Case 2: malformed read happens even before exec

Run ID:

acp_agent:main:main_1773225025043

Sequence from logs:

embedded run start ... provider=kimi-coding model=k2p5
read tool called without path ...
embedded run tool start ... tool=read
...
embedded run tool start ... tool=exec
embedded run tool end ... tool=exec

So exec is not the root cause. It only often appears in failing sessions because the agent is doing multi-step tool planning.

Regression signal

From my archived logs:

  • older runtime signatures (22.22.0) show only a small number of read tool called without path events
  • newer runtime signatures (25.8.1) show a much larger number of these events

This strongly suggests the issue became materially worse after upgrading OpenClaw.

Why I think this is an OpenClaw regression

  • Same Kimi Coding key + same endpoint works fine in direct Anthropic-compatible API tests
  • exec tool arguments are valid in direct tests
  • read tool arguments are also valid in direct tests
  • Failures are occurring inside OpenClaw's real runtime during multi-tool execution
  • The bad payload is specifically the tool-call input object OpenClaw receives from the model during runtime

Expected behavior

On current OpenClaw builds, Kimi Coding (k2p5) via https://api.kimi.com/coding/ should preserve valid tool-call arguments the same way it does in direct API tests.

Actual behavior

On current OpenClaw builds, Kimi Coding sessions intermittently emit malformed read tool calls without path, causing file operations to fail and derailing the run.

Related issue

This seems related in symptom family to closed stale issue #15809, but that one was about Moonshot Direct / OpenAI-compatible routing. This new report is for the official Kimi Code Anthropic-compatible endpoint on current OpenClaw builds.

Request

Please test Kimi Coding (k2p5) on current OpenClaw builds using the official Anthropic-compatible endpoint and multi-step tool workflows that involve exec followed by file reads. My current evidence suggests the regression is in OpenClaw's Kimi integration rather than the provider endpoint itself.

extent analysis

Fix Plan

To resolve the issue of malformed read tool calls in OpenClaw's Kimi Coding integration, follow these steps:

  1. Update the Kimi Coding provider configuration: Ensure that the baseUrl and api fields are correctly set to use the Anthropic-compatible endpoint.
    {
      "baseUrl": "https://api.kimi.com/coding/",
      "api": "anthropic-messages",
      "models": [{ "id": "k2p5" }]
    }
  2. Verify tool call argument handling: Review the OpenClaw code responsible for handling tool call arguments, particularly for the read tool. Ensure that the path or file_path parameter is correctly extracted and passed to the read tool.
  3. Implement input validation: Add input validation to ensure that the read tool call arguments are valid before executing the tool.
    if (!toolCallArgs.path && !toolCallArgs.file_path) {
      throw new Error("Missing required parameter: path or file_path");
    }
  4. Test multi-step tool workflows: Thoroughly test Kimi Coding sessions using the official Anthropic-compatible endpoint and multi-step tool workflows that involve exec followed by file reads.

Verification

To verify that the fix worked:

  1. Run test cases: Execute test cases that previously failed due to malformed read tool calls.
  2. Monitor logs: Check the OpenClaw logs for any errors related to malformed read tool calls.
  3. Verify tool call arguments: Confirm that the read tool call arguments are correctly passed and executed.

Extra Tips

  • Regularly review and update the OpenClaw code to ensure compatibility with the latest Kimi Coding API changes.
  • Consider implementing additional logging and error handling to help identify and diagnose issues more efficiently.
  • Test OpenClaw with different Kimi Coding models and API endpoints to ensure broader compatibility.

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…

FAQ

Expected behavior

On current OpenClaw builds, Kimi Coding (k2p5) via https://api.kimi.com/coding/ should preserve valid tool-call arguments the same way it does in direct API tests.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING