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

@shubham-021
Copy link
Contributor

@shubham-021 shubham-021 commented Dec 2, 2025

Background

The @ai-sdk/huggingface provider uses the OpenAI Responses API format, which requires tool results to be sent using function_call_output items. However, the current implementation only handles server-side tools and throws an "unsupported tool messages" warning when encountering client-side tool results (messages with role: 'tool'), causing the tool result to be skipped entirely

Summary

Added function_call_output conversion for client-side tool execution

Changes Made:

  • Added HuggingFaceResponsesFunctionCallOutput type to match Responses API spec
  • Replaced the "unsupported tool messages" warning with proper conversion logic
    - Converts role: 'tool' messages to function_call_output format
  • Updated existing test to verify no warnings are produced
  • Added test to verify function_call_output appears in request body

Manual Verification

  • Added huggingface-tool-bug.ts file in example/ai-core/src/generate-text which produces the issue without the fix , with fix it produces the expected result.

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)

Fixes : #10766

@shubham-021
Copy link
Contributor Author

@aayush-kapoor please review this PR when you get a chance. Thank you.

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.

[@ai-sdk/huggingface] Error with hugging face and tools

1 participant