Skip to content

[BUG] Free Code resubmits a tool result after a post-tool provider disconnect #38

Description

@N0zoM1z0

Summary

After Free Code submits a completed shell tool result, a transient disconnect in the provider recovery stream causes the same tool result to be submitted again. The standalone reproducer builds public Free Code source at db7d2165a708a9b4904e74bd2e1ab7753bf60901, starts a local mock provider, closes the follow-up stream mid-response, and verifies duplicate tool-result submission without requiring this repository or any private fuzzing harness.

Affected target

  • Target: Free Code
  • Affected version checked with the public reproducer: db7d2165a708a9b4904e74bd2e1ab7753bf60901
  • Current public main checked on 2026-06-19: db7d2165a708a9b4904e74bd2e1ab7753bf60901
  • Environment: Linux x86_64 Docker, public source build
  • Provider/model: Anthropic-compatible local mock provider, claude-3-5-sonnet-20241022

Steps to reproduce

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 the affected CLI from public source, 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/1c2db900f5aef155cc647458cb7ba6d2

The Gist contains free-code-post-tool-transient-disconnect.reproduce.py. Download and run:

gh gist clone 1c2db900f5aef155cc647458cb7ba6d2 free-code-post-tool-transient-disconnect-reproducer
cd free-code-post-tool-transient-disconnect-reproducer
python3 free-code-post-tool-transient-disconnect.reproduce.py

To reuse an already-built local image:

python3 free-code-post-tool-transient-disconnect.reproduce.py --skip-build

Key output from a local run against the affected version:

provider_requests_at_least: observed=3 expected>=2
closed_mid_stream_at_least: observed=2 expected>=1
duplicate_tool_result disconnect_probe: observed=2 expected>=2
REPRODUCED

Actual behavior

Free Code submits the disconnect_probe tool result twice after the provider follow-up stream disconnects mid-response. The reproducer prints REPRODUCED only when it observes provider traffic, a closed mid-stream response, and duplicate tool-result submission for the same call ID.

Expected behavior

Free Code should treat a completed provider-issued tool-call ID as committed, and a retry/recovery path should not resubmit the same tool result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions