Skip to content

Conversation

AntonioVFranco
Copy link

Summary

Robust JSON repair and schema validation for LLM-produced plans, plus integration into PlanningFlow with a safe fallback.

Changes

  • Add app/planning/:
    • models.py (Plan, Step, extra='forbid')
    • json_repair.py (fences, smart quotes, JS comments, trailing commas incl. whitespace, in-string newline/tab escaping, single-missing brace/ bracket balance, 30% sanity guard)
    • collector.py (extract → repair → json.loadsPlan.model_validate)
    • metrics.py (lightweight counters)
    • integrations.py (parse_plan_text() adapter with env toggle)
  • Wire parse_plan_text() into app/flow/planning.py with a strict json.loads + Plan.model_validate fallback.
  • Log planning repair metrics in PlanningFlow.
  • Docs: docs/planning-json-repair.md.

Toggle

  • Default: enabled (repair + validate).
  • Disable (strict mode): OPENMANUS_PLANNING_REPAIR=0.

Backwards compatibility / rollback

  • Fully backwards compatible: fallback path keeps legacy behavior.
  • Rollback: set OPENMANUS_PLANNING_REPAIR=0 to force strict mode.

Testing

  • Local: export PYTHONPATH=$PWD && pytest -q tests/planning (9 passing).
  • Pre-commit hooks are green.

Notes

  • Title and commits follow Conventional Commits.

@AntonioVFranco
Copy link
Author

Hi! This PR adds robust plan JSON repair & schema validation and wires it into PlanningFlow (with a strict fallback). Could you please review? Maintainers’ edits are allowed.

cc @mannaandpoem @XiangJinyu @MoshiQAQ @didiforgithub @stellaHSR @fred913

@AntonioVFranco
Copy link
Author

On the Checks tab I'm seeing "Workflow runs completed with no jobs". Could a maintainer enable/run workflows for this PR or confirm that path filters make this expected?

Local verification: pytest -q tests/planning (9 passing) and pre-commit hooks are green. Thanks!

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