Before HuggingGPT runs a plan, it has to be well formed: every referenced task exists and the dependencies do not loop. Rejecting a bad plan early avoids running part of it and then failing.
Implement is_valid_plan(tasks), returning whether the plan can be executed.
First check that every dependency is a known task. Then check the graph is acyclic by counting how many tasks a dependency-respecting pass can reach.
No results yet
Run your code to check it against the examples, or submit to run every test.