WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@pablof7z
Copy link

@pablof7z pablof7z commented Dec 4, 2025

Description

Backport of #10734 to the v5.0 release branch.

Problem

Provider-executed dynamic tools (like Claude Code's built-in Bash tool) are being incorrectly validated in parseToolCall, causing them to be marked as invalid: true even though they execute successfully on the provider side.

This results in error messages being sent back to the model:

Model tried to call unavailable tool 'Bash'. No tools are available.

The model then gets confused and apologizes for tools it just successfully used.

Root Cause

The parseToolCall function validates ALL tool calls against the user's tools map, without checking if the tool has providerExecuted: true. Provider-executed tools aren't in the user's tools map because they're managed by the provider, not the application.

Solution

Add checks for toolCall.providerExecuted && toolCall.dynamic before attempting validation in two places:

  1. When tools == null (line 31-33)
  2. When tool is not found in tools map (line 111-113)

If both flags are true, call parseProviderExecutedDynamicToolCall to handle the tool call without validation.

Testing

Tested with ai-sdk-provider-claude-code v2.2.3. Before fix:

  • Tool calls marked as invalid: true
  • Error messages sent to model
  • Model apologizes for successfully used tools

After fix:

  • Tool calls properly recognized with providerExecuted: true
  • No validation errors
  • Model responds normally

Related Issues

Checklist

  • Added logic to skip validation for provider-executed dynamic tools
  • Added parseProviderExecutedDynamicToolCall helper function
  • Imported DynamicToolCall type
  • Tested with real-world provider (ai-sdk-provider-claude-code)
  • No breaking changes to existing behavior

Backport of vercel#10734 to v5.0 release branch.

Provider-executed dynamic tools (like Claude Code's built-in tools) should
skip validation since they're not in the user's tools map. This fix adds
checks for toolCall.providerExecuted && toolCall.dynamic before attempting
validation, preventing NoSuchToolError for provider-managed tools.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant