Repository navigation
Conversation
…ng it _convert_tool_response_to_text fell back to str(message) for BLOB messages, so binary tool output reached the model as escaped bytes -- about three times the payload, up to the 30 MB merge cap in merge_blob_chunks -- and was unreadable. The API persists blobs as tool files before rendering text (ToolFileMessageTransformer); until that pipeline exists here, report the mimetype and size instead. Refs langgenius#42114.
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 issue
Refs #42114.
What changed
_convert_tool_response_to_textindify-agent/src/dify_agent/layers/dify_plugin/tools_layer.pynow rendersBLOBmessages as a bounded description instead of falling back tostr(message).Before this change a plugin tool that returned binary output (an image, a PDF, a generated archive) reached the model as
blob=b'\x89PNG\r\n\x1a\n...'.str()escapes every byte, so the observation is roughly three times the payload — measured 2056 bytes of PNG turning into a 5905 character observation — and the merge cap inmerge_blob_chunksallows that to grow to 30 MB. The model cannot read the bytes anyway.Now the observation is
binary output (image/png, 2056 bytes) is not included in the text result, falling back toapplication/octet-streamwhen the daemon sends nomime_type.The API never inlines these bytes:
ToolFileMessageTransformer.transform_tool_invoke_messagespersists aBLOBas a tool file first and rewrites it to anIMAGE_LINK/BINARY_LINK(api/core/tools/utils/message_transformer.py). This PR does not port that file pipeline — it only stops the unbounded inlining. The full fix is #43099, which has been conflicting withmainsince 2026-09-28.Verification
Added
test_native_plugin_tool_describes_binary_output_instead_of_inlining_itindify-agent/tests/local/dify_agent/layers/dify_plugin/test_layers.py, parametrised over ablobframe that carriesmime_type: image/pngand one that carries nometaat all.assert "blob=b'\x89PNG...fd\xfe\xff'" == 'binary output (...)'.uv run python -m pytest tests/local/dify_agent/layers/dify_plugin/test_layers.py -q→ 15 passed.ruff checkandruff format --checkare clean.tests/localon this branch: 22 failed / 1025 passed / 2 errors, the same 22 environment failures as onmain(e2b SDK version mismatch,openshellhas no Windows wheel,python3shell scripts).AI assistance
Written with AI assistance. The tests above were run locally on Windows; an end-to-end plugin-daemon run was not possible there because
openshellships no Windows wheel.