yania-n Claude Sonnet 4.6 commited on
Commit
f07628a
·
1 Parent(s): f39699c

fix: strip full opening fence line in parse_plan_json to remove language identifier

Browse files
Files changed (1) hide show
  1. core/planner.py +5 -4
core/planner.py CHANGED
@@ -87,12 +87,13 @@ class ProjectPlan(BaseModel):
87
  def parse_plan_json(raw: str) -> ProjectPlan:
88
  """Parse a raw JSON string into a validated ProjectPlan. Returns empty plan on error."""
89
  try:
90
- # Strip markdown code fences if present
91
  text = raw.strip()
 
92
  if text.startswith("```"):
93
- # Remove opening fence (e.g. ```json or ```)
94
- text = text.split("\n", 1)[1] if "\n" in text else text[3:]
95
- # Remove closing fence
 
96
  if text.rstrip().endswith("```"):
97
  text = text.rstrip()[:-3].rstrip()
98
 
 
87
  def parse_plan_json(raw: str) -> ProjectPlan:
88
  """Parse a raw JSON string into a validated ProjectPlan. Returns empty plan on error."""
89
  try:
 
90
  text = raw.strip()
91
+ # Strip markdown code fences (e.g. ```json ... ``` or ``` ... ```)
92
  if text.startswith("```"):
93
+ # Drop the entire opening fence line (```json, ```python, or just ```)
94
+ first_newline = text.find("\n")
95
+ text = text[first_newline + 1:] if first_newline != -1 else text[3:]
96
+ # Drop the closing fence
97
  if text.rstrip().endswith("```"):
98
  text = text.rstrip()[:-3].rstrip()
99