Repository navigation
fix(model)!: match literal stop sequences - #406
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The implementation satisfies the stated behavior, with focused regression coverage and clear compatibility documentation.
0 open findings
What changed in this PR
Updates the SDK’s public stop helper to match literal text rather than regular expressions.
Changes:
- Returns the prefix before the earliest stop, regardless of list order.
- Expands regression coverage for punctuation, backslashes, overlapping stops, and empty inputs.
- Documents the SDK 0.11.0 compatibility change and migration guidance.
| File | Description |
|---|---|
| tests/interfaces/model/test_llm_stop_tokens.py | Tests literal matching and edge cases. |
| src/dify_plugin/interfaces/model/large_language_model.py | Replaces regex splitting with literal searches. |
| README.md | Documents behavior and migration requirements. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
hjlarry
approved these changes
Oct 20, 2026
This was referenced Nov 2, 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.
Delivery status — 2026-11-02
Merged on 2026-10-21.
The fix is included in the planned SDK 0.11.0 release for Dify 1.19.0, tracked in #413.
The public SDK remains 0.10.2; plugin delivery follows publication.
The public stop helper interpreted stop strings as regular expressions: a period could erase the entire answer,
[END]matched individual letters, and an empty list also returned an empty answer.Use literal string searches and return the prefix before the earliest match, regardless of stop-list order.
Closes #400.
Compatibility for SDK 0.11.0 (unreleased): stop strings are literal, including punctuation and backslashes.
An empty list or no match returns the full input; an empty string in the list still matches at the start.
Callers using regex patterns must migrate to actual stop text, for example
r"\."to".".The README documents the change.
No production callers were found in this SDK or dify-official-plugins at f2d781136.
The Azure OpenAI plugin's existing stop helper already uses its own literal search.
External callers were not available to inspect.
Validation:
just check,just test(1,479 passed), andjust build.The focused cases cover punctuation, backslashes, literal and actual newlines, ordinary stops, overlapping stops in either order, empty inputs, empty stop lists, and no matches.
Pull Request Checklist
Thank you for your contribution! Before submitting your PR, please make sure you have completed the following checks:
Compatibility Check
README.mdREADME.mdREADME.mdREADME.mdThe target release is documented as 0.11.0; maintainer discussion is pending review of this PR.
Available Checks
just buildhas passed