Skip to content

Conversation

@aayush-kapoor
Copy link
Contributor

@aayush-kapoor aayush-kapoor commented Jan 28, 2026

Background

anthropic's deferred tool loading allows custom tool search implementations that return tool_reference blocks, but we didn't support this format. reference here

Summary

added support for custom tool-reference content for deferred tool loading

Manual Verification

verified via a reproduction script given by the user in examples/ai-functions/src/generate-text/11829-repro.ts (will be deleted after review)

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)

Related Issues

fixes #11829

Copy link
Collaborator

@lgrammel lgrammel left a comment

Choose a reason for hiding this comment

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

this is a potential breaking specification change that needs to wait until ai sdk 7

Comment on lines 426 to 438
| {
/**
* Custom content part. This can be used to implement
* provider-specific content parts.
*/
type: 'custom';

/**
* Provider-specific options.
*/
providerOptions?: SharedV3ProviderOptions;
}
>;
Copy link
Contributor Author

@aayush-kapoor aayush-kapoor Jan 28, 2026

Choose a reason for hiding this comment

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

@lgrammel what if we added the type in custom object instead to avoid breaking changes

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's a good use of it, since it's a single provider that needs tool-reference content so far

@lgrammel
Copy link
Collaborator

Looks good. PR title and description are out of date. Presumably there is no way to do this without using a special tool result part?

@aayush-kapoor aayush-kapoor changed the title feat(anthropic): add 'tool-reference' content type for deferred loading Jan 29, 2026
@aayush-kapoor
Copy link
Contributor Author

Presumably there is no way to do this without using a special tool result part?

unfortunately no - they need a tool_reference object in the content part of the tool result to map the result.

also updated the PR description and title; ready for review again

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