Fix/Process content if the structuredContent are null#4252
Merged
brian-hussey merged 2 commits intomainfrom Apr 16, 2026
Merged
Fix/Process content if the structuredContent are null#4252brian-hussey merged 2 commits intomainfrom
brian-hussey merged 2 commits intomainfrom
Conversation
Signed-off-by: Suresh Kumar Moharajan <suresh.kumar.m@ibm.com>
Signed-off-by: Brian Hussey <brian.hussey@ie.ibm.com>
f4e6af7
8649eaa to
f4e6af7
Compare
brian-hussey
approved these changes
Apr 16, 2026
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.
Fix OutputLengthGuard plugin null structuredContent handling
🔗 Related Issue
Closes #4248
📝 Summary
Fixed a bug in the OutputLengthGuard plugin where tool output was not being truncated when
structuredContentwas explicitly set tonull. The plugin was checking for key presence but not validating the value, causing it to enter the structured content processing branch with a null value and skip content array processing entirely.Changes:
structuredContentkey validation inoutput_length_guard.py(lines 249-254)test_null_structured_content_processes_content_array()to verify the fixImpact:
structuredContent: nullnow correctly have theircontentarray truncated🏷️ Type of Change
🧪 Verification
make lintmake testmake coverageTest Coverage:
test_null_structured_content_processes_content_array()✅ Checklist
make black isort pre-commit)📓 Notes
Root Cause
The plugin's logic checked for the presence of the
structuredContentkey but didn't validate whether the value wasnull:When tools returned
{"structuredContent": null, "content": [...]}, the plugin would:structuredContentkey existsTesting
The new test verifies the exact scenario from issue #4248:
structuredContent: nullwith a 63-character content arraymax_output_length: 10Next Steps for Verification