openclaw - 💡(How to fix) Fix Duplicate tool call ID error with Kimi/moonshot model [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#51410Fetched 2026-04-08 01:11:33
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
commented ×1

OpenClaw throws "duplicated tool call ID" error when using moonshot/kimi-k2.5 model, causing HTTP 400 errors and failed responses.

Error Message

400: {"error":{"message":"duplicated tool call ID: write:509","type":"invalid_request_error","param":null,"code":null}}

Root Cause

OpenClaw throws "duplicated tool call ID" error when using moonshot/kimi-k2.5 model, causing HTTP 400 errors and failed responses.

Fix Action

Fix / Workaround

Workarounds Attempted

  • Gateway restart: ❌ No effect
  • Fresh session (/new): ⚠️ Temporary relief
  • Simpler commands: ⚠️ Reduces frequency but doesn't eliminate

Code Example

400: {"error":{"message":"duplicated tool call ID: write:509","type":"invalid_request_error","param":null,"code":null}}
RAW_BUFFERClick to expand / collapse

Bug Report: Duplicate Tool Call ID Error with Kimi/moonshot Model

Summary

OpenClaw throws "duplicated tool call ID" error when using moonshot/kimi-k2.5 model, causing HTTP 400 errors and failed responses.

Environment

  • OpenClaw Version: 2026.3.13 (61d171a)
  • Model: moonshot/kimi-k2.5
  • OS: Ubuntu 24.04.4 LTS (Linux 6.8.0-106-generic)
  • Node: v22.22.1
  • Install Method: pnpm
  • Channel: stable

Error Message

400: {"error":{"message":"duplicated tool call ID: write:509","type":"invalid_request_error","param":null,"code":null}}

Steps to Reproduce

  1. Start OpenClaw with moonshot/kimi-k2.5 model
  2. Send any message that triggers tool calls (e.g., "Hello", file operations)
  3. Error appears intermittently, especially with multiple tool calls in one turn

Expected Behavior

Tool calls should execute without duplicate ID errors.

Actual Behavior

OpenClaw rejects the response with "duplicated tool call ID" error.

Frequency

  • Intermittent but frequent
  • Persists after gateway restart
  • Affects simple and complex queries

Additional Context

  • Error occurs even with basic "Hello" messages
  • Gateway restart does not resolve
  • Multiple sessions show same issue
  • Appears to be framework-level tool call generation issue

Workarounds Attempted

  • Gateway restart: ❌ No effect
  • Fresh session (/new): ⚠️ Temporary relief
  • Simpler commands: ⚠️ Reduces frequency but doesn't eliminate

Related

  • Possibly related to how Kimi model generates tool call IDs
  • May need deduplication logic in OpenClaw's tool call handler

extent analysis

Fix Plan

To resolve the "duplicated tool call ID" error, we need to implement a deduplication mechanism in OpenClaw's tool call handler.

Steps to Fix

  • Step 1: Implement a Set to Store Tool Call IDs Create a set to store generated tool call IDs and check for duplicates before sending the tool call.
  • Step 2: Modify the Tool Call Handler Modify the tool call handler to generate a new ID if a duplicate is found.

Example Code

// Create a set to store tool call IDs
const toolCallIds = new Set();

// Function to generate a unique tool call ID
function generateToolCallId() {
  let id;
  do {
    // Generate a new ID (e.g., using UUID)
    id = crypto.randomUUID();
  } while (toolCallIds.has(id));
  toolCallIds.add(id);
  return id;
}

// Modify the tool call handler to use the new ID generator
function handleToolCall() {
  const id = generateToolCallId();
  // Send the tool call with the new ID
  sendToolCall(id);
}

Verification

To verify the fix, restart OpenClaw and send multiple messages that trigger tool calls. Check for the "duplicated tool call ID" error in the response. If the error is resolved, the fix is successful.

Extra Tips

  • Consider implementing a timeout or removal mechanism for tool call IDs to prevent the set from growing indefinitely.
  • Review the Kimi model's tool call ID generation logic to ensure it is not causing the duplication issue.

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