Repository navigation
fix(sleep): read the first JSON value from a chatty CLI reply - #456
Open
Lenin Mookiah (leninworld) wants to merge 1 commit into
Open
Lenin Mookiah (leninworld) wants to merge 1 commit into
Lenin Mookiah (leninworld) wants to merge 1 commit into
Conversation
This branch has not been deployed
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
_extract_jsoninskillopt_sleep/backend.pysays it pulls the first JSON object or array out of a chatty CLI reply, but it matched a greedy\{.*\}/\[.*\]span from the first opening delimiter to the last closing one. Any other brace or bracket around the JSON (a judge restating{score, reason}, a trailingSee [1]) made that span invalid, so the reply parsed asNone. The judge then scoredjudge-parse-failed(0), and reflect, the LLM miner, rollout reflection and the slow update got no edits or tasks.Changes
_extract_jsontries each{(or[) left to right withjson.JSONDecoder().raw_decodeand returns the first value that decodes, orNone. Whenever the old greedy span decoded, that value starts at the first opener, so replies that parsed before give the same result. It catchesValueErrorandRecursionError, so a reply that returnedNonebefore can't raise now.CHANGELOG.md: entry under Fixed.Tests
New
tests/test_sleep_extract_json.py:Both fail on main (they get
None) and pass with the fix. Full suite: 2418 passed, 23 skipped, 4 xfailed, plus 2 failures intests/test_sleep_adopt_skill_subset.py(the tampered-manifest tests). Those 2 fail the same way on main on this machine (macOS, Python 3.12) and are unrelated.ruff checkpasses on the new test file. It reports nothing in the changed function; the 7 findings elsewhere inbackend.pyare already on main.Fixes #455