Feature/schedule
Summary of Changes
Hello, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a foundational task scheduling framework, enabling more sophisticated management and execution of tasks within the system. It centralizes task state handling, provides flexible scheduling strategies, and refines the event-driven architecture with more precise lifecycle hooks. These changes lay the groundwork for advanced automation and workflow orchestration, ensuring tasks are processed efficiently and reliably according to defined schedules and dependencies.
Highlights
- Comprehensive Task Scheduling System Introduced: A new, robust task scheduling system has been implemented, featuring a TaskManager for persistence, a TaskScheduler supporting various strategies (FIFO, Priority, DAG, Auto), and dedicated types for schedulable and scheduled tasks with cron, one-time, and delayed execution capabilities.
- Refactored Task Status Management: The task status system has been standardized and improved by converting
TaskStatusValueto an enum-likeTaskStatus(str)and introducing a newDISABLEDstatus, enhancing type consistency and clarity across the codebase. - Enhanced Hook Point System: The runner's hook point system has been significantly refactored to provide more granular lifecycle events, moving from generic 'Pre/Post' hooks to specific 'OnStart', 'OnFinished', 'OnSuccess', and 'OnError' hooks for LLM calls, tool calls, and tasks.
- Codebase Cleanup and Simplification: Numerous unused imports and redundant code sections have been removed, particularly in
aworld/core/common.py,aworld/core/task.py, andaworld/runners/handler/background_task.py, contributing to a cleaner and more maintainable codebase.
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.
Changelog
- aworld/core/common.py
- Removed an empty line for cleaner formatting
- Added a new
DISABLEDstatus toTaskStatusValue - Changed
TaskStatusValueto inherit fromstrand renamed it toTaskStatus - Introduced
TaskTypeValueenum forINSTANTandSCHEDULEDtask types
- aworld/core/context/amni/init.py
- Removed the import of
TaskStatusfromaworld.core.common
- Removed the import of
- aworld/core/context/amni/contexts.py
- Updated the import of
TaskStatusValuetoTaskStatus
- Updated the import of
- aworld/core/context/amni/state/task_state.py
- Updated the import of
TaskStatusfromaworld.core.tasktoaworld.core.common
- Updated the import of
- aworld/core/context/base.py
- Removed
TaskStatusValuefromTYPE_CHECKINGimports - Updated
get_task_statusmethod to useTaskStatus.SUCCESSinstead ofTaskStatusValue.SUCCESS
- Removed
- aworld/core/event/message_future.py
- Replaced
TaskStatusValuewithTaskStatusin thewaitmethod for status checks
- Replaced
- aworld/core/task.py
- Removed unused imports:
asyncio,enum,Literal,TYPE_CHECKING - Updated
task_statusfield default fromTaskStatusValue.INITtoTaskStatus.INIT - Updated
statusfield default inTaskResponsefromTaskStatusValue.SUCCESStoTaskStatus.SUCCESS
- Removed unused imports:
- aworld/evaluations/scorers/output_validators.py
- Removed
model_configarguments fromscorer_registerdecorators forOutputRelevanceScorer,OutputCompletenessScorer, andOutputQualityScorer
- Removed
- aworld/events/util.py
- Replaced
TaskStatusValuewithTaskStatusinsend_message,send_and_wait_message, and_send_finish_messagefunctions
- Replaced
- aworld/runners/event_runner.py
- Updated import of
TaskStatusValuetoTaskStatus - Replaced
TaskStatusValuewithTaskStatusin various task status updates within the runner
- Updated import of
- aworld/runners/handler/background_task.py
- Removed several unused imports including
asyncio,time,EnvChannelMessage,ContextManager,Runners, andHookPoint - Replaced
TaskStatusValuewithTaskStatusin task status handling - Commented out code related to
EnvChannelMessageprocessing
- Removed several unused imports including
- aworld/runners/handler/task.py
- Updated import of
TaskStatusValuetoTaskStatus - Replaced
TaskStatusValuewithTaskStatusin task status updates for failed, cancelled, and interrupted tasks
- Updated import of
- aworld/runners/hook/agent_hooks.py
- Removed
abcimport and__metaclass__ = abc.ABCMetafrom hook classes - Changed base classes for
PreLLMCallContextProcessHookandPostLLMCallContextProcessHooktoOnStartLLMCallHookandOnFinishedLLMCallHookrespectively - Removed empty
execmethod implementations from hook classes
- Removed
- aworld/runners/hook/hook_factory.py
- Removed the import of
StartHook
- Removed the import of
- aworld/runners/hook/hooks.py
- Removed
ModelResponseimport - Refactored
HookPointconstants to introduce more granular LLM, tool, and task lifecycle events (e.g.,ON_START_LLM_CALL,ON_SUCCESS_TASK) - Removed
__metaclass__ = abc.ABCMetafrom all hook classes - Provided a default
passimplementation for theexecmethod in the baseHookclass - Removed
PreToolCallHook,PostToolCallHook,PreTaskCallHook, andPostTaskCallHookclasses
- Removed
- aworld/runners/hook/task_hooks.py
- Added new file defining specific task lifecycle hooks:
OnRunHook,OnSuccessHook,OnErrorHook,OnStartHook, andOnFinishHook
- Added new file defining specific task lifecycle hooks:
- aworld/runners/hook/tool_hooks.py
- Added new file defining specific tool call lifecycle hooks:
OnStartToolCallHook,OnFinishedToolCallHook,OnToolCallHook,OnSuccessToolCallHook, andOnErrorToolCallHook
- Added new file defining specific tool call lifecycle hooks:
- aworld/runners/task_manager.py
- Added new file implementing
TaskManagerfor managing task persistence, CRUD operations, status-based retrieval, and ready task detection
- Added new file implementing
- aworld/schedule/init.py
- Added new empty
__init__.pyfile to mark the directory as a Python package
- Added new empty
- aworld/schedule/scheduler.py
- Added new file implementing
TaskSchedulerfor managing and executing scheduled tasks, supporting various scheduling strategies, resource quotas, and periodic task handling
- Added new file implementing
- aworld/schedule/strategy.py
- Added new file defining abstract
ScheduleStrategyand concrete implementations likeFIFOStrategy,PriorityStrategy,DAGStrategy, andAutoStrategy - Introduced
TaskQueuebase class withFIFOTaskQueue,PriorityTaskQueue, andResourceAwareTaskQueueimplementations
- Added new file defining abstract
- aworld/schedule/task_graph.py
- Added new file implementing
TaskGraphfor Directed Acyclic Graph (DAG) based task scheduling, including methods for adding tasks, getting ready tasks, marking completion/failure, determining execution order, and cycle detection
- Added new file implementing
- aworld/schedule/types.py
- Added new file defining data classes for
SchedulableTaskandScheduledTask ScheduledTasksupports cron expressions, one-time scheduling, and delayed execution, along with time range constraints and execution limits- Introduced
TaskStatisticsfor tracking global scheduling state andResourceQuotafor managing machine resources
- Added new file defining data classes for
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.