Skip to content
Learn Agentic AI16 min read0 views

AI Agent for Student Enrollment: Course Registration, Schedule Building, and Advising

Build an AI enrollment agent that helps students register for courses, checks prerequisites, optimizes class schedules, and routes complex advising questions to human advisors.

The Registration Bottleneck

Course registration week is chaos at most universities. Students compete for limited seats, struggle with prerequisite chains, build schedules with time conflicts, and flood advisor inboxes with questions. An AI enrollment agent can resolve the majority of these issues instantly by checking prerequisites, detecting conflicts, suggesting alternatives, and only escalating genuinely complex cases to human advisors.

Course Catalog Data Model

A robust enrollment agent needs a well-structured course catalog with prerequisite relationships.

from dataclasses import dataclass, field
from enum import Enum
from typing import Optional


class DayOfWeek(Enum):
    MON = "Monday"
    TUE = "Tuesday"
    WED = "Wednesday"
    THU = "Thursday"
    FRI = "Friday"


@dataclass
class TimeSlot:
    days: list[DayOfWeek]
    start_hour: int  # 24-hour format
    start_minute: int
    end_hour: int
    end_minute: int

    def overlaps(self, other: "TimeSlot") -> bool:
        shared_days = set(self.days) & set(other.days)
        if not shared_days:
            return False
        self_start = self.start_hour * 60 + self.start_minute
        self_end = self.end_hour * 60 + self.end_minute
        other_start = other.start_hour * 60 + other.start_minute
        other_end = other.end_hour * 60 + other.end_minute
        return self_start < other_end and other_start < self_end


@dataclass
class Course:
    code: str
    title: str
    credits: int
    department: str
    prerequisites: list[str] = field(default_factory=list)
    corequisites: list[str] = field(default_factory=list)
    max_enrollment: int = 30
    current_enrollment: int = 0
    time_slot: Optional[TimeSlot] = None
    instructor: str = ""
    description: str = ""

    @property
    def seats_available(self) -> int:
        return self.max_enrollment - self.current_enrollment

    @property
    def is_full(self) -> bool:
        return self.current_enrollment >= self.max_enrollment


@dataclass
class StudentRecord:
    student_id: str
    name: str
    major: str
    completed_courses: list[str] = field(default_factory=list)
    current_schedule: list[str] = field(default_factory=list)
    credits_completed: int = 0
    max_credits_per_semester: int = 18

Prerequisite Checker

The most critical function is verifying that a student meets all prerequisites before registering.

COURSE_CATALOG: dict[str, Course] = {}
STUDENT_RECORDS: dict[str, StudentRecord] = {}


def check_prerequisites(
    student_id: str, course_code: str
) -> dict:
    student = STUDENT_RECORDS.get(student_id)
    course = COURSE_CATALOG.get(course_code)
    if not student or not course:
        return {"eligible": False, "reason": "Student or course not found"}

    missing_prereqs = [
        prereq for prereq in course.prerequisites
        if prereq not in student.completed_courses
    ]
    if missing_prereqs:
        return {
            "eligible": False,
            "reason": "Missing prerequisites",
            "missing": missing_prereqs,
            "suggestion": f"Complete {', '.join(missing_prereqs)} first",
        }

    current_credits = sum(
        COURSE_CATALOG[c].credits
        for c in student.current_schedule
        if c in COURSE_CATALOG
    )
    if current_credits + course.credits > student.max_credits_per_semester:
        return {
            "eligible": False,
            "reason": "Would exceed maximum credit limit",
            "current_credits": current_credits,
            "course_credits": course.credits,
            "max_allowed": student.max_credits_per_semester,
        }

    return {"eligible": True, "reason": "All prerequisites met"}

Schedule Conflict Detection

Before adding a course, the agent must verify there are no time conflicts.

See AI Voice Agents Handle Real Calls

Book a free demo or calculate how much you can save with AI voice automation.

def detect_schedule_conflicts(
    student_id: str, new_course_code: str
) -> list[dict]:
    student = STUDENT_RECORDS.get(student_id)
    new_course = COURSE_CATALOG.get(new_course_code)
    if not student or not new_course or not new_course.time_slot:
        return []

    conflicts = []
    for enrolled_code in student.current_schedule:
        enrolled = COURSE_CATALOG.get(enrolled_code)
        if not enrolled or not enrolled.time_slot:
            continue
        if enrolled.time_slot.overlaps(new_course.time_slot):
            conflicts.append({
                "conflicting_course": enrolled.code,
                "conflicting_title": enrolled.title,
                "conflicting_time": f"{enrolled.time_slot.days} "
                    f"{enrolled.time_slot.start_hour}:"
                    f"{enrolled.time_slot.start_minute:02d}",
            })
    return conflicts

Building the Enrollment Agent Tools

from agents import Agent, function_tool, Runner
import json


@function_tool
def search_courses(department: str, keyword: str = "") -> str:
    """Search the course catalog by department and optional keyword."""
    results = []
    for code, course in COURSE_CATALOG.items():
        if course.department.lower() != department.lower():
            continue
        if keyword and keyword.lower() not in course.title.lower():
            continue
        results.append({
            "code": code,
            "title": course.title,
            "credits": course.credits,
            "seats_available": course.seats_available,
            "instructor": course.instructor,
        })
    return json.dumps(results) if results else "No courses found."


@function_tool
def register_for_course(student_id: str, course_code: str) -> str:
    """Attempt to register a student for a course after all checks."""
    prereq_result = check_prerequisites(student_id, course_code)
    if not prereq_result["eligible"]:
        return json.dumps(prereq_result)

    course = COURSE_CATALOG[course_code]
    if course.is_full:
        return json.dumps({
            "registered": False,
            "reason": "Course is full",
            "waitlist_available": True,
        })

    conflicts = detect_schedule_conflicts(student_id, course_code)
    if conflicts:
        return json.dumps({
            "registered": False,
            "reason": "Schedule conflict detected",
            "conflicts": conflicts,
        })

    student = STUDENT_RECORDS[student_id]
    student.current_schedule.append(course_code)
    course.current_enrollment += 1
    return json.dumps({
        "registered": True,
        "course": course.title,
        "updated_schedule": student.current_schedule,
    })


enrollment_agent = Agent(
    name="Enrollment Advisor",
    instructions="""You are a university enrollment advisor agent.
    Help students search for courses, check prerequisites, register
    for classes, and build conflict-free schedules. When a student
    cannot register, explain why clearly and suggest alternatives.
    If a question requires human judgment (academic probation,
    override requests, degree audits), say you will route to a
    human advisor.""",
    tools=[search_courses, register_for_course],
)

FAQ

How does the agent handle waitlists when a course is full?

Add a waitlist data structure that tracks position and automatically enrolls students when seats open. The agent tool returns the waitlist position and estimated chance of getting in based on historical drop rates for that course.

Can this agent replace human academic advisors?

No. The agent handles routine tasks — prerequisite checks, schedule building, course search — freeing advisors for complex decisions like degree pathway planning, academic probation guidance, and career counseling. The agent should always route nuanced questions to human advisors.

How do you handle cross-listed courses and lab sections?

Model cross-listed courses as separate entries sharing a linked_course_group field. When a student registers for one section, the agent checks enrollment across all linked sections. Lab sections use a corequisite relationship so the agent enforces paired enrollment.


#AIAgents #EdTech #CourseRegistration #Python #Education #AgenticAI #LearnAI #AIEngineering

Share this article
C

CallSphere Team

Expert insights on AI voice agents and customer communication automation.

Try CallSphere AI Voice Agents

See how AI voice agents work for your industry. Live demo available -- no signup required.