fix: support ComponentTool deserialization in OpenAI and Azure responses chat generators - #12485
Open
rautaditya2606 wants to merge 1 commit into
Conversation
rautaditya2606
requested review from
julian-risch
and
a lite review from Copilot
and removed request for
a team
August 27, 2026 08:01
|
@rautaditya2606 is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
…ses chat generators
rautaditya2606
force-pushed
the
fix/responses-chat-generator-tool-deserialization
branch
from
August 27, 2026 08:18
cf6fc3e to
290f219
Compare
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
Closes #12484
Proposed Changes
OpenAIResponsesChatGenerator.from_dict()andAzureOpenAIResponsesChatGenerator.from_dict()to correctly detect serialized Haystack tools using the{"type": ..., "data": ...}serialization envelope instead of matching only"haystack.tools.tool.Tool".ComponentToolinstances while preserving raw OpenAI tool definitions.Root Cause
from_dict()previously determined whether a tool required deserialization using:This fails for
ComponentTool, whose serialized representation uses:{ "type": "haystack.tools.component_tool.ComponentTool", "data": {...} }As a result, the serialized dictionary remained in
toolsinstead of being deserialized.When
run()was subsequently called,_prepare_api_call()interpreted the dictionary as a raw OpenAI tool definition and passed the Haystack serialization structure to the OpenAI API, resulting in a400 Bad Request.Fix
The implementation now identifies serialized Haystack tools based on the presence of the
"data"serialization envelope.This allows
ComponentTooland other serialized Haystack tools to be deserialized correctly while continuing to support raw OpenAI tool definitions such as:{ "type": "function", ... }Reproducer
Before the fix:
After the fix:
Tests
Ran the affected test suites:
hatch -e test run pytest \ test/components/generators/chat/test_openai_responses.py \ test/components/generators/chat/test_azure_responses.pyResult:
Also ran the newly added tests specifically:
Result:
Checklist