Skip to content

Qwen Code sends duplicate tool-result history for a reused tool-call id #5099

Description

@N0zoM1z0

What happened?

When the provider reuses tool-call id dup_id_0001 across turns, Qwen Code sends duplicate tool-result entries for that id back to the provider. This can corrupt provider conversation state, trigger provider-side schema errors, or amplify retries.

In the latest local verification run, the standalone reproducer observed 587 duplicate tool_result entries for dup_id_0001 before timeout.

What did you expect to happen?

Qwen Code should reject, ignore, or coalesce duplicate provider tool-call ids before executing tools or appending tool results to provider history.

Client information

Client Information
Qwen Code: 0.17.1
Package: @qwen-code/qwen-code
Runtime: Node.js from node:24-bookworm target image
OS: Linux x86_64 Docker
Interface: CLI
Command shape: qwen --chat-recording=false --auth-type openai --model gpt-4 --approval-mode yolo --output-format text
Provider: OpenAI Chat-compatible local mock provider

Login information

API Config with a local OpenAI-compatible mock provider and dummy API key vendor-repro-fake-key.

Anything else we need to know?

Prerequisites: Docker, Python 3, and the GitHub CLI (gh) for the clone command below. The linked reproducer is self-contained and uses only Python standard-library modules plus Docker. It builds @qwen-code/[email protected] from the public npm package, starts a local mock provider, and runs the CLI in an isolated workspace. The Docker run is limited to 2 CPUs and 4 GiB RAM by default.

Complete self-contained reproducer: https://gist.github.com/N0zoM1z0/403d8953e9c9eca8708df82ac73fd1f5

gh gist clone 403d8953e9c9eca8708df82ac73fd1f5 qwen-duplicate-tool-id-history-pollution-reproducer
cd qwen-duplicate-tool-id-history-pollution-reproducer
python3 qwen-duplicate-tool-id-history-pollution.reproduce.py

To reuse an already-built local image:

python3 qwen-duplicate-tool-id-history-pollution.reproduce.py --skip-build

Expected successful reproduction output includes:

provider_requests=588
duplicate_tool_result_in_request dup_id_0001: observed=587 expected>=2
REPRODUCED

Metadata

Metadata

Assignees

Labels

category/coreCore engine and logiccategory/toolsTool integration and executionpriority/P2Medium - Moderately impactful, noticeable problemtype/bugSomething isn't working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions