fix: constrained decoding cache bug and task rotation#199
Merged
Conversation
Constrained decoding: - Remove (.|\n)* prefix from action regex — Outlines can't compile it into a DFA efficiently. Model must output action directly. - Fix cache sentinel: use False for failure (not []) so subsequent calls correctly return None instead of empty logits_processor list. Prior bug: [] cached as "success" → model generated unconstrained. - Upgrade warning to error level for visibility. Task rotation: - Fix _load_task_configs: check `not task_ids` once BEFORE the loop (was checking inside loop — only first task ever appended). Tests (21 new): - TestActionRegex: 8 valid actions match, 6 invalid texts rejected - TestConstrainedDecodingCache: sentinel logic, regression for [] bug - TestTaskRotation: all tasks loaded, explicit ids preserved, rotation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Mar 28, 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.
Summary
Fixes two bugs reported by customer on their first standalone trainer run:
Constrained decoding not activating: Outlines
RegexLogitsProcessorfailed silently on DFA compilation (the(.|\n)*prefix was too complex). Failure was cached as[]which passed theis not Nonecheck, somodel.generate()received an emptylogits_processorlist — unconstrained output. Fixed: removed prefix from regex (model must output action directly), useFalsesentinel for failures.Task rotation stuck on first task:
_load_task_configscheckedif not self._config.task_idsinside the loop — after appending the first task, the list was non-empty so remaining tasks were skipped. Fixed: check once before the loop.Tests
21 new tests covering:
[]no longer treated as successful cacheAll 21 pass in 0.03s, no GPU or server required.
Test plan
constrained_decoding=Trueand verifies structured output🤖 Generated with Claude Code