Skip to content

Conversation

@ussef083
Copy link

@ussef083 ussef083 commented Dec 2, 2025

…ool_search_tool_regex, tool_search_tool_bm25) + new tool parameters (defer_loading, input_examples, allowed_callers)

Background

Anthropic recently introduced new advanced built-in tools and capabilities:
https://www.anthropic.com/engineering/advanced-tool-use

I have added 2 new built in tools: tool_search_tool_bm25 and tool_search_tool_regex
plus adding support for 3 tool parameters: defer_loading, allowed_callers, input_examples

Summary

Manual Verification

Checklist

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Future Work

Related Issues

…ool_search_tool_regex, tool_search_tool_bm25) + new tool parameters (defer_loading, input_examples, allowed_callers)
@ussef083 ussef083 closed this Dec 2, 2025

export async function getAnthropicAdvancedToolUseFeaturesSupport(
providerMetadata: SharedV3ProviderMetadata | undefined,
): Promise<AnthropicAdvancedToolUse | undefined> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
): Promise<AnthropicAdvancedToolUse | undefined> {
): Promise<AnthropicAdvancedToolUse> {

The return type annotation for getAnthropicAdvancedToolUseFeaturesSupport declares it may return undefined, but the function always returns an AnthropicAdvancedToolUse object, never undefined.

View Details

Analysis

Incorrect return type annotation in getAnthropicAdvancedToolUseFeaturesSupport

What fails: The function getAnthropicAdvancedToolUseFeaturesSupport() in packages/anthropic/src/advanced-tool-use.ts has return type Promise<AnthropicAdvancedToolUse | undefined>, but the implementation always returns an AnthropicAdvancedToolUse object and never returns undefined.

How to reproduce:

// In packages/anthropic/src/advanced-tool-use.ts, line 28
export async function getAnthropicAdvancedToolUseFeaturesSupport(
  providerMetadata: SharedV3ProviderMetadata | undefined,
): Promise<AnthropicAdvancedToolUse | undefined> {  // Claims it may return undefined
  // ... validation logic ...
  let result: AnthropicAdvancedToolUse = {};  // Line 51: initialized as empty object
  if (parseDeferLoading !== undefined) {
    result.defer_loading = parseDeferLoading;
  }
  // ... more conditional assignments ...
  return result;  // Line 64: Always returns result object, never undefined
}

Result: Function always returns an object (at minimum an empty AnthropicAdvancedToolUse object). The | undefined union is never satisfied. The type annotation is misleading to callers and TypeScript static analysis.

Expected: Return type should be Promise<AnthropicAdvancedToolUse> without the | undefined union.

Fix applied: Changed return type annotation from Promise<AnthropicAdvancedToolUse | undefined> to Promise<AnthropicAdvancedToolUse> on line 28. Full build passes with no errors.

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