Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ tests/skill_engine/*
!tests/skill_engine/test_evolver_length_recovery.py
!tests/skill_engine/test_evolution_retry_idempotency.py
!tests/skill_engine/test_analyzer_length_recovery.py
!tests/skill_engine/test_registry_skill_selection_json.py
!tests/skill_engine/decision/
tests/skill_engine/decision/*
!tests/skill_engine/decision/test_analysis_adapter.py
Expand Down
10 changes: 5 additions & 5 deletions openspace/skill_engine/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1888,13 +1888,13 @@ def _parse_skill_selection_response(content: str) -> tuple[List[str], str]:
if code_block:
content = code_block.group(1).strip()
else:
# Try to find a raw JSON object
json_match = re.search(r"\{.*\}", content, re.DOTALL)
if json_match:
content = json_match.group()
# Prefer the first object start; raw_decode ignores trailing prose.
brace = content.find("{")
if brace >= 0:
content = content[brace:]

try:
data = json.loads(content)
data, _ = json.JSONDecoder().raw_decode(content)
except json.JSONDecodeError:
logger.warning(f"Failed to parse LLM skill selection JSON: {content[:200]}")
return [], ""
Expand Down
12 changes: 12 additions & 0 deletions tests/skill_engine/test_registry_skill_selection_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Regression: trailing prose with braces must not drop skill-selection JSON."""

from __future__ import annotations

from openspace.skill_engine.registry import SkillRegistry


def test_parse_skill_selection_tolerates_trailing_prose_braces():
text = '{"brief_plan": "ok", "skills": ["a"]}\n\nnote {x}'
ids, plan = SkillRegistry._parse_skill_selection_response(text)
assert ids == ["a"]
assert plan == "ok"