Repository navigation
fix: redact ImageContent and FileContent in ToolCallResult trace dicts - #12824
Conversation
|
@rautaditya2606 is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
A critical sequence-handling leak and a moderate serialization-efficiency issue remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Fixes tracing leaks by redacting base64 payloads nested in ToolCallResult.
Changes:
- Adds trace-specific redaction for image and file content.
- Routes tool results through trace serialization.
- Adds regression tests and a release note.
| File | Summary | Findings |
|---|---|---|
test/dataclasses/test_chat_message.py |
Adds redaction regression tests. | None |
releasenotes/notes/redact-tool-call-result-traces-03ffd820959a52da.yaml |
Documents the fix. | None |
haystack/dataclasses/chat_message.py |
Implements redaction and dispatch logic. | Critical (3 votes): handle tuple and other Sequence values. Moderate (1 vote): avoid duplicate recursive serialization. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
8cbf01d to
a34ee47
Compare
|
hello @julian-risch, just giving this a gentle bump when you have a moment to review. All CI checks are passing. I have another bug fix ready to submit (#13109), but I'm currently holding off due to the community open PR limit. Thanks! |
f8e315d to
4f6c092
Compare
|
hello @sjrl, ive implemented both suggestions |


Related Issues
Closes #12823
Proposed Changes
ToolCallResult._to_trace_dict()to redact large base64 binary payloads inImageContentandFileContentwhen serialized for tracing.Sequencecontent (lists, tuples, custom sequences) and avoided duplicate recursive serialization by constructing the trace dictionary directly.ChatMessage._to_trace_dict()to dispatch toToolCallResult._to_trace_dict().Root Cause
ChatMessage._to_trace_dict()redacts large binary payloads in top-levelImageContentandFileContent, but had no branch forToolCallResult. Furthermore,ToolCallResultdid not implement_to_trace_dict().As a result, when tools returned multimodal content (such as
ImageContentorFileContent), tracing spans serialized them via defaultto_dict(), leaking full, unredacted multi-megabyte base64 strings into telemetry backends.Fix
ToolCallResult._to_trace_dict()to inspect parts inself.resultfor anySequenceand redactImageContentorFileContentobjects to placeholder strings ("Base64 string (N characters)").to_dict()/asdict()to avoid duplicate recursive serialization and memory overhead.isinstance(part, ToolCallResult)branch inChatMessage._to_trace_dict().Reproducer
Before the fix:
After the fix:
Tests
Ran the affected test suites:
hatch -e test run pytest test/dataclasses/test_chat_message.py test/tracing/test_utils.pyResult:
Also ran the newly added tests specifically:
Result:
Quality checks:
hatch run fmt hatch -e test run mypy haystack/dataclasses/chat_message.py test/dataclasses/test_chat_message.pyResult:
Checklist