Handle None
content in stop-sequence trimming
#1826
+26
−2
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.
Prevent stop-sequence trimming from crashing on tool-only GPT-5 outputs
Linked Issue
Fixes Bug #1825
Summary
remove_content_after_stop_sequences
from crashing when a provider returnscontent=None
(e.g.gpt-5
tool-only turns).None
stop list to avoid accidental truncation.Details
content=None
andstop_sequences=None
as no-op cases so we only trim when actual text is present.gpt-5
tool-calling without changing behavior for normal string outputs.Tests
tests/test_models.py::test_remove_content_after_stop_sequences_handles_none
– confirms the helper returnsNone
when the provider emits tool-only output, mirroring the bug scenario.tests/test_models.py::test_remove_content_after_stop_sequences_ignores_empty_stop_sequences
– ensures harmless empty stop strings do not strip valid text.tests/test_models.py::test_remove_content_after_stop_sequences_with_none_stop_sequences
– protects the default code path wherestop_sequences
isNone
, preserving existing behavior.Thanks a lot for feedback and support!