openclaw - ✅(Solved) Fix [Bug]: Tool Parameter Serialization Failure [1 pull requests, 1 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#54978Fetched 2026-04-08 01:33:57
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
labeled ×2subscribed ×2cross-referenced ×1

Version: OpenClaw 2026.3.24 (cff6dc9)
Environment: Windows 10, Node v24.14.0, PowerShell
Model: kimi/k2p5

Error Message

  1. Error returned:
  • Different error messages between read and exec suggest inconsistent parameter alias handling
  1. Observed: Error Received arguments: {} read({"path":"./file.md"}) → Error: "Missing required parameter: path alias"

Root Cause

Version: OpenClaw 2026.3.24 (cff6dc9)
Environment: Windows 10, Node v24.14.0, PowerShell
Model: kimi/k2p5

Fix Action

Workaround

Use CLI commands as alternatives (e.g., curl instead of web_fetch).


指挥官,英文版已准备好。可直接复制到 GitHub Issues 或 Discord 反馈。

PR fix notes

PR #54491: fix(kimi): preserve valid Anthropic-compatible toolCall arguments in malformed-args repair path

Description (problem / solution / changelog)

Summary

  • Problem: When using Kimi in Anthropic-compatible (anthropic-messages) mode, the malformed toolCall-arguments repair logic could fail to preserve otherwise-valid JSON arguments (resulting in missing/empty tool arguments).
  • Why it matters: Tool execution depends on correct toolCall.arguments; losing valid arguments can cause wrong tool behavior, failures, or unexpected “empty args” executions.
  • What changed: Adjusted the Kimi/Anthropic toolCall-argument repair path to keep valid, complete JSON arguments intact and only apply “balanced-prefix + short trailing junk” repair when the arguments are actually malformed.
  • What did NOT change (scope boundary): No changes to tool dispatch logic, tool allowlists, transcript storage, or non-Kimi providers.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause / Regression History (if applicable)

  • Root cause: The malformed-args repair wrapper for Kimi/Anthropic streams treated some valid toolCall argument payloads as candidates for repair, and under certain stream delta patterns it could clear/override arguments instead of preserving the complete JSON object.
  • Missing detection / guardrail: Unit coverage focused on “valid JSON + short trailing junk” but didn’t adequately lock in “valid JSON must remain unchanged” across all relevant stream delta/event sequences.
  • Prior context (git blame, prior PR, issue, or refactor if known): Unknown.
  • Why this regressed now: Likely triggered by Kimi’s Anthropic-compatible streaming behavior (toolcall deltas containing } early / nested JSON / event chunking), which increased the chance the heuristic attempted repair at the wrong time.
  • If unknown, what was ruled out: Not an auth/key issue and not a tool registry/dispatch mismatch; reproduces at the stream parsing/repair layer.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/agents/pi-embedded-runner/run/attempt.test.ts (malformed toolCall args repair tests)
  • Scenario the test should lock in: When toolCall arguments are already valid JSON (including nested objects), the repair path must not alter or clear them; when valid JSON is followed by 1–3 trailing junk characters, it should repair to the valid object.
  • Why this is the smallest reliable guardrail: This bug is purely in the stream repair/parsing layer; unit tests can deterministically simulate deltas/events without requiring a live model.
  • Existing test that already covers this (if any): The suite includes a test for “trailing junk follows valid JSON”; this PR strengthens/extends coverage to ensure valid JSON remains intact.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

None (except improved reliability of tool execution for Kimi Anthropic-compatible runs).

Security Impact (required)

  • New permissions/capabilities? (Yes/No): No
  • Secrets/tokens handling changed? (Yes/No): No
  • New/changed network calls? (Yes/No): No
  • Command/tool execution surface changed? (Yes/No): No
  • Data access scope changed? (Yes/No): No
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: Node.js (local)
  • Model/provider: kimi-coding/k2p5
  • Integration/channel (if any): N/A
  • Relevant config (redacted): Provider set to kimi, model API anthropic-messages

Steps

  1. Configure provider kimi with Anthropic-compatible API (anthropic-messages).
  2. Trigger a tool call where arguments are a valid nested JSON object (e.g. {"path":{"a":"/tmp/report.txt"}}) and/or where streaming deltas include early } tokens.
  3. Observe tool call arguments during/after stream assembly.

Expected

  • Valid JSON arguments are preserved exactly and passed to tool execution unchanged.

Actual

  • Arguments could be cleared/overwritten in the repair path, resulting in incomplete or empty arguments passed to tools.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios: Ran the unit tests for the malformed toolCall-arguments repair and confirmed that the final assembled message preserves valid arguments; also confirmed that the “short trailing junk” repair still works. Before the fix, with Kimi in Anthropic-messages streaming mode, multiple consecutive tool_call invocations could carry empty arguments; after the fix, empty-argument tool calls no longer occur.
  • Edge cases checked: -
  • What you did not verify: -

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? (Yes/No): Yes
  • Config/env changes? (Yes/No): No
  • Migration needed? (Yes/No): No
  • If yes, exact upgrade steps: N/A

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: Revert this commit; alternatively disable the Kimi/Anthropic malformed-args repair wrapper if maintainers prefer.
  • Files/config to restore: src/agents/pi-embedded-runner/run/attempt.ts
  • Known bad symptoms reviewers should watch for: Tool calls executed with {}/missing required parameters; intermittent tool failures only on Kimi Anthropic-compatible runs.

Risks and Mitigations

  • Risk: Repair logic might still be triggered too aggressively for some unusual streaming chunk patterns.
    • Mitigation: Keep repair gated to Kimi + anthropic-messages, retain strict trailing-suffix limits, and add/extend unit coverage for representative delta sequences.

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/agents/pi-embedded-runner/run/attempt.test.ts (modified, +86/-0)
  • src/agents/pi-embedded-runner/run/attempt.tool-call-argument-repair.ts (modified, +18/-6)

Code Example

{"command": "echo test"}

---

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

---
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Summary

Version: OpenClaw 2026.3.24 (cff6dc9)
Environment: Windows 10, Node v24.14.0, PowerShell
Model: kimi/k2p5

Issue Description

When calling tools that require parameters, the parameters fail to serialize and pass to the Runtime layer. Validation errors show received arguments as empty object {}.

Reproduction Steps

  1. Start any session
  2. Attempt to call a tool with parameters, e.g.:
    {"command": "echo test"}
  3. Error returned:
    Validation failed for tool "exec":
    - command: must have required property 'command'
    Received arguments: {}

Test Results

ToolParametersResult
session_statusnone✅ Works
exec{"command": "..."}❌ Parameters lost
web_fetch{"url": "..."}❌ Parameters lost
read{"path": "..."}❌ "Missing required parameter: path alias"

Key Observations

  • Parameter-less tools work fine, ruling out basic connectivity issues
  • Different error messages between read and exec suggest inconsistent parameter alias handling
  • Configuration appears normal (gateway.mode: local, port: 18789)

Impact

All parameter-requiring tools are non-functional, severely limiting capabilities.

Workaround

Use CLI commands as alternatives (e.g., curl instead of web_fetch).


指挥官,英文版已准备好。可直接复制到 GitHub Issues 或 Discord 反馈。

Steps to reproduce

  1. Start OpenClaw session with model kimi/k2p5
  2. Invoke tool: exec with payload {"command":"echo test"}
  3. Observed: Error Received arguments: {}
  4. Invoke tool: session_status with no payload
  5. Observed: Success — returns session info Deterministic evidence: Parameter-less tools succeed; parameterized tools fail with empty args.

Expected behavior

Expected: exec({"command":"echo test"}) → executes command, returns output web_fetch({"url":"https://example.com"}) → returns page content read({"path":"./file.md"}) → returns file content Reference: Tool schemas define these parameters as required. Session logs show tools are invoked but parameters are not serialized to Runtime.

Actual behavior

exec({"command":"echo test"}) → Validation failed: "command: must have required property 'command'", Received arguments: {} web_fetch({"url":"https://example.com"}) → Validation failed: "url: must have required property 'url'", Received arguments: {} read({"path":"./file.md"}) → Error: "Missing required parameter: path alias" session_status({}) → Success (returns session info) Evidence: All parameterized tools fail with empty arguments {}; parameter-less tools succeed.

OpenClaw version

2026.3.24

Operating system

window 11

Install method

npm global

Model

kimi/k2p5

Provider / routing chain

User (WebChat) → OpenClaw Gateway (local, ws://127.0.0.1:18789) → kimi/k2p5 (Kimi API)

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

Fix Plan

The issue seems to be related to parameter serialization when calling tools. To fix this, we need to ensure that the parameters are properly serialized and passed to the Runtime layer.

Step 1: Update the Tool Invocation Code

We need to update the code that invokes the tools to properly serialize the parameters. We can use the JSON.stringify() method to serialize the parameters to a JSON string.

// Before
invokeTool('exec', { command: 'echo test' });

// After
const params = { command: 'echo test' };
invokeTool('exec', JSON.stringify(params));

Step 2: Update the Runtime Layer to Parse JSON Parameters

We need to update the Runtime layer to parse the JSON parameters. We can use the JSON.parse() method to parse the JSON string to a JavaScript object.

// Before
const params = {}; // empty object

// After
const params = JSON.parse(toolParams);

Step 3: Verify Parameter Serialization

We need to verify that the parameters are properly serialized and passed to the Runtime layer. We can add logging statements to check the serialized parameters.

console.log('Serialized params:', JSON.stringify(params));

Verification

To verify that the fix worked, we can test the tools with parameters again.

  1. Start a new session.
  2. Invoke a tool with parameters, e.g., exec with payload {"command": "echo test"}.
  3. Check the output to ensure that the command is executed correctly.
  4. Repeat step 2 with other tools that require parameters, e.g., web_fetch and read.

Extra Tips

  • Make sure to update the code to handle any potential errors that may occur during parameter serialization and parsing.
  • Consider adding additional logging statements to help diagnose any issues that may arise.
  • If you're using a framework or library to handle tool invocation, check the documentation to see if there are any built-in features for handling parameter serialization.

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

Expected: exec({"command":"echo test"}) → executes command, returns output web_fetch({"url":"https://example.com"}) → returns page content read({"path":"./file.md"}) → returns file content Reference: Tool schemas define these parameters as required. Session logs show tools are invoked but parameters are not serialized to Runtime.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING