[FEATURE] Allow model to abort/discard a tool call mid-generation

Resolved 💬 3 comments Opened Mar 26, 2026 by cathackk Closed Apr 26, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

When Claude is generating a tool call (e.g., a Bash script), it sometimes realizes mid-generation that the approach is wrong — an import won't work, a path doesn't exist, or the logic needs a fundamentally different approach. But it cannot abort: once generation of a tool call has started, it must produce complete output. The result is incoherent spliced scripts (half one approach, half another) that the user has to reject, wasting a round-trip.

Proposed Solution

A mechanism for the model to signal "discard this tool call, give me a fresh turn." This could be a special abort token emitted during tool call generation that tells the runtime to discard the partial output and let the model start a new response. The user would see nothing (or a brief "Claude changed approach") rather than broken output.

Alternative Solutions

  • "Think before you tool" — encourage the model to plan more before starting a tool call. Helps but doesn't eliminate the problem; debugging is inherently unpredictable.
  • User-side: the existing interrupt/reject mechanism works but requires the user to notice the bad output and manually intervene.

Priority

Medium - Would be very helpful

Feature Category

API and model interactions

Use Case Example

During a debugging session, Claude starts writing a Python script that imports a project module directly. Mid-script, it realizes the module has dependencies that won't resolve in the current context. Instead of stopping, it pivots inside the same script to reading the source file with open() as a fallback. The resulting script is incoherent — half import-based, half file-reading — and fails. The user rejects it, and Claude starts fresh with a clean approach that works on the first try. The abort token would have skipped the broken intermediate output entirely.

Additional Context

Observed with Claude Code (Opus 4.6) during extended debugging sessions where wrong paths are frequent. The problem is most visible in Bash/Python tool calls where the model constructs multi-step logic and discovers mid-way that a prerequisite doesn't hold.

Related issues: #35576 (stuck in wrong tool call loop), #31841 (wrong approach first, self-corrects after failure).

Example of partway re-reasoning, see the last three lines:

.venv/bin/python -c "
import tiktoken

enc = tiktoken.get_encoding('cl100k_base')

with open('~/Temp/cap.txt') as f:
    text = f.read()

print(f'Total text: {len(text)} chars, {len(enc.encode(text))} tokens')
print()

# Simulate the chunker with max_chunk_size=2000
# Let's check how the Azure Search built-in chunker works vs our custom one
# Our chunker is in skill_function/skill/chunker.py
from importlib.util import spec_from_file_location, module_from_spec
import sys

spec = spec_from_file_location('chunker', 'skill_function/skill/chunker.py')
mod = module_from_spec(spec)
sys.modules['skill.models'] = type(sys)('skill.models')  # stub

# Actually let me just read the chunker code to understand the algorithm
with open('skill_function/skill/chunker.py') as f:
    print(f.read()[:2000])
"

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗