fix: #10063 prevent oversized tracing payloads for ByteStream and Ima…#10081
Closed
jovicdev97 wants to merge 0 commit into
Closed
fix: #10063 prevent oversized tracing payloads for ByteStream and Ima…#10081jovicdev97 wants to merge 0 commit into
jovicdev97 wants to merge 0 commit into
Conversation
|
@jovicdev97 is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Thank you for the quick response! Have you tested the scenario of a list of ChatMessage with oversized ImageContent? I think that is probably the most important and the most problematic one in terms of tracing. ChatMessage.to_dict() would call ImageContent.to_dict() directly, and that might escape the special handling logic. |
Contributor
|
Hey @jovicdev97 thanks for the contribution! However, since this change affects a core part of our tracing functionality, we’d prefer to handle it internally. If you’d like to explore other ways to contribute, feel free to check out our Contributions Wanted board: Haystack - Contributions wanted |
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
Proposed Changes:
This PR optimizes how ByteStream and ImageContent objects are serialized during tracing to prevent oversized payloads, which fixes #10063
Previously, tracing these objects would attempt to serialize their full binary or base64 content, leading to massive trace sizes. The updated logic in _serializable_value:
ByteStream: Now excludes the raw data payload. Instead, it captures metadata (mime type, size in bytes) and generates a short text preview (first 100 bytes) if the content is text-based.
ImageContent: Now excludes the full base64_image. It captures metadata and provides a truncated preview of the base64 string.
General: Added a helper _get_text_preview to safely decode and truncate text previews.
How did you test it?
I added comprehensive unit tests in test/tracing/test_utils.py covering the following scenarios:
ByteStream Binary: Verifying that large binary data is excluded from serialization while retaining metadata (size_bytes, mime_type).
ByteStream Text: Verifying that text-based streams generate a correct, truncated preview string.
ImageContent: Verifying that large base64 strings are truncated to prevent payload bloat.
Nested Structures: Verifying that these objects are correctly handled when nested inside lists or dictionaries.
Type Coercion: Verifying coerce_tag_value handles these objects correctly via the updated serialization logic.
Notes for the reviewer
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.