Skip to content

fix(skill_engine): parse skill-selection JSON despite trailing brace prose#109

Open
santhreal wants to merge 1 commit into
HKUDS:mainfrom
santhreal:fix/registry-skill-json-trailing
Open

fix(skill_engine): parse skill-selection JSON despite trailing brace prose#109
santhreal wants to merge 1 commit into
HKUDS:mainfrom
santhreal:fix/registry-skill-json-trailing

Conversation

@santhreal

Copy link
Copy Markdown

Problem

SkillRegistry._parse_skill_selection_response used a greedy \{.*\} match before json.loads. When the LLM returned valid skill-selection JSON followed by prose that contained braces, the match swallowed the trailing text, parsing failed, and selection returned empty ([], "").

Repro

from openspace.skill_engine.registry import SkillRegistry

text = '{"brief_plan": "ok", "skills": ["a"]}\n\nnote {x}'
print(SkillRegistry._parse_skill_selection_response(text))
# before: ([], '')
# after:  (['a'], 'ok')

Fix

Find the first { and use json.JSONDecoder().raw_decode, matching the analyzer/capture parsers.

Test

pytest tests/skill_engine/test_registry_skill_selection_json.py -q

Greedy \{.*\} matching dropped valid skill-selection objects when the
LLM appended prose that contained braces. Use raw_decode from the first
brace instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant