Skip to content

fix(anthropic): return tool_result for every tool_use on reask - #2486

Closed
Solaris-star wants to merge 1 commit into
567-labs:mainfrom
Solaris-star:fix/2485-parallel-tools-reask-tool-results
Closed

fix(anthropic): return tool_result for every tool_use on reask#2486
Solaris-star wants to merge 1 commit into
567-labs:mainfrom
Solaris-star:fix/2485-parallel-tools-reask-tool-results

Conversation

@Solaris-star

Copy link
Copy Markdown

Summary

When Anthropic returns multiple tool_use blocks (normal for Mode.PARALLEL_TOOLS) and a validation error triggers a reask, handle_reask only kept the last tool_use_id. Anthropic requires a tool_result for every prior tool_use, so the retry request itself failed with:

400 invalid_request_error: tool_use ids were found without tool_result blocks

Fix

Collect all tool_use ids and emit one tool_result per id (same error content, is_error=True).

Test

python -m pytest tests/coverage/test_anthropic_handlers_coverage.py -q
# 24 passed

Regression assertion now checks all three tool_use_ids are present.

Fixes #2485

Anthropic requires a tool_result for each tool_use block in the prior
turn. handle_reask only kept the last tool_use id, so PARALLEL_TOOLS
reasks dropped earlier results and the retry itself failed with 400.

Collect all tool_use ids and emit one tool_result per id.

Fixes 567-labs#2485
@AJ-ing

AJ-ing commented Jul 25, 2026

Copy link
Copy Markdown

Looks correct — collecting every tool_use id and asserting all tool_result blocks is exactly what Anthropic requires for PARALLEL_TOOLS reasks. Thanks for also updating the test that previously locked in last-id-only behavior.

@jxnl

jxnl commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Consolidated and shipped in #2495. Closing this focused patch as superseded; thank you for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(anthropic): handle_reask drops tool_result for all but the last tool_use block in PARALLEL_TOOLS mode

3 participants