Rule-Based AI Task Planner Project

Artificial Intelligence project 19

Rule-Based AI Task Planner Project

Build a complete rule-based ai task planner workflow with reproducible Python code, transparent inputs, reviewable output, and responsible-use limits.

Explore AI training in VizagView all project ideas

AI objective

Produce a valid execution order in which every prerequisite appears before the dependent task.

Data or knowledge source

An input goal plus explicit task definitions and prerequisite relationships.

Requirements

  • Python 3.10 or later
  • A terminal or command prompt
  • No third-party packages required
  • About 45-60 minutes to build and review

How the system works

Add domain-specific tasks from goal keywords and run a depth-first topological sort with unknown-dependency and cycle checks.

Validation checklist

  • Every dependency appears before its consumer
  • Cycles raise an error
  • Unknown dependencies raise an error
  • The rules remain fully visible to the user

Complete Python code

Save the program as ai_rule_based_task_planner.py. The code runs locally and requires no paid API key or model download.

"""A symbolic AI task planner using explicit prerequisites."""

from __future__ import annotations

from dataclasses import dataclass


@dataclass(frozen=True)
class Task:
    name: str
    depends_on: tuple[str, ...] = ()


def tasks_for_goal(goal: str) -> dict[str, Task]:
    lower = goal.lower()
    tasks = {
        "clarify": Task("clarify"),
        "research": Task("research", ("clarify",)),
        "draft": Task("draft", ("research",)),
        "review": Task("review", ("draft",)),
        "deliver": Task("deliver", ("review",)),
    }
    if "publish" in lower or "website" in lower:
        tasks["test_links"] = Task("test_links", ("review",))
        tasks["deliver"] = Task("deliver", ("review", "test_links"))
    if "data" in lower or "report" in lower:
        tasks["validate_data"] = Task("validate_data", ("research",))
        tasks["draft"] = Task("draft", ("research", "validate_data"))
    return tasks


def topological_plan(tasks: dict[str, Task]) -> list[str]:
    ordered, visiting, visited = [], set(), set()
    def visit(name: str) -> None:
        if name in visiting:
            raise ValueError("Dependency cycle detected")
        if name in visited:
            return
        if name not in tasks:
            raise ValueError(f"Unknown dependency: {name}")
        visiting.add(name)
        for dependency in tasks[name].depends_on:
            visit(dependency)
        visiting.remove(name)
        visited.add(name)
        ordered.append(name)
    for task_name in tasks:
        visit(task_name)
    return ordered


def main() -> None:
    print(topological_plan(tasks_for_goal("Analyse data, write a report, and publish it on a website")))
    print("This symbolic planner follows visible rules; it does not understand hidden constraints.")


if __name__ == "__main__":
    main()

Run the project

  1. Create and activate a virtual environment.
  2. Install dependencies with No third-party packages required when packages are required.
  3. Run python ai_rule_based_task_planner.py.
  4. Review confidence, fallbacks, sources, or error metrics rather than accepting output automatically.
  5. Test additional normal, edge, unsupported, and adversarial inputs.

Expected output

An ordered list of task names for the selected goal.

Accuracy, privacy, and responsible-use limits

This symbolic planner follows keywords and declared rules; it does not understand hidden constraints, permissions, cost, safety, or whether a task should be performed.

Ways to extend the project

Add durations, resource constraints, alternative plans, approval gates, plan explanations, recovery paths, and validation before external actions.

Continue learning Artificial Intelligence

Try the next project, return to the Softenant project library, or explore the AI training in Vizag for guided NLP, retrieval, evaluation, automation, and responsible AI practice.