Tasks Module¶
Overview¶
The tasks
module in the AgenticAI Framework manages the creation, scheduling, and execution of tasks for AI agents. It provides a structured way to define workflows, assign responsibilities, and track progress.
Key Classes and Functions¶
- Task — Represents a single unit of work with metadata and execution logic.
- TaskScheduler — Schedules tasks for execution at specific times or intervals.
- TaskQueue — Manages a queue of pending tasks.
- execute_task(task_id) — Executes a task by its identifier.
- list_tasks(status=None) — Lists tasks filtered by their status (pending, in-progress, completed).
Example Usage¶
from agenticaiframework.tasks import Task, TaskScheduler
# Define a task
task = Task(name="Data Processing", description="Process incoming data files.")
# Initialize scheduler
scheduler = TaskScheduler()
scheduler.add_task(task)
# Execute tasks
scheduler.run_pending()
Use Cases¶
- Automating repetitive workflows.
- Scheduling periodic data processing jobs.
- Coordinating multi-step AI agent operations.
- Tracking the status of long-running processes.
Best Practices¶
- Keep task definitions modular and reusable.
- Use descriptive names and metadata for easier tracking.
- Handle task failures gracefully with retries or fallbacks.
- Monitor task execution times to identify bottlenecks.