[codex] Harden JSON array extraction#103
Draft
zixuanguo786-ctrl wants to merge 1 commit into
Draft
Conversation
LLM responses can include bracketed prose before the actual JSON array. The old greedy regex spanned from the first '[' to the last ']', causing valid single-array answers to be dropped and making multiple arrays indistinguishable. Constraint: Keep object extraction behavior unchanged. Rejected: Return first parseable array | silently guesses when a response has multiple valid arrays. Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep array extraction conservative when more than one valid top-level array is present. Tested: uv run --with pytest pytest tests/test_json_utils.py -q Tested: uv run --with ruff ruff check skillopt/utils/json_utils.py tests/test_json_utils.py Not-tested: Full benchmark rollouts.
Contributor
|
@zixuanguo786-ctrl please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
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
Test plan
uv run --with pytest pytest tests/test_json_utils.py -quv run --with ruff ruff check skillopt/utils/json_utils.py tests/test_json_utils.py