Bug fixs: Coerce str back to bytes for bytes-typed HookToolset parameters#70433
Open
ColtenOuO wants to merge 1 commit into
Open
Bug fixs: Coerce str back to bytes for bytes-typed HookToolset parameters#70433ColtenOuO wants to merge 1 commit into
ColtenOuO wants to merge 1 commit into
Conversation
HookToolset advertises bytes parameters to the LLM as JSON strings (there's no bytes type in JSON), but call_tool never converted them back before invoking the hook method. A method like S3Hook.load_bytes would receive a str where bytes is required, failing at runtime with an opaque TypeError from BytesIO.
Contributor
Author
|
It looks like the CI needs to be restarted. |
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.
Summary
HookToolsetadvertises a hook method'sbytes-typed parameters to the LLM as JSON strings (_TYPE_MAPmapsbytes->{"type": "string"}, since JSON has no binary type), butcall_toolnever converted the string back tobytesbefore calling the method. A hook method likeS3Hook.load_bytes(bytes_data: bytes, ...)would receive a plainstr, failing at runtime with an opaqueTypeError: a bytes-like object is required, not 'str'fromBytesIO.Changes
_bytes_param_names(method)to resolve which parameters (includingOptional[bytes]/bytes | None) arebytes-typed.call_toolnow UTF-8-encodes anystrvalue supplied for those parameters before dispatching to the hook method.Was generative AI tooling used to co-author this PR?