Skip to content

Conversation

@danyalxahid-askui
Copy link
Contributor

@danyalxahid-askui danyalxahid-askui commented Dec 24, 2025

Context

Background Scheduling functionality implementation.

Includes:

  • Scheduling Message Rerunner
  • List Scheduling
  • Delete Schedules

…essage creation

Enhanced the `create_message` method in `MessageService` to include an optional parameter `inject_cancelled_tool_results`. When set to `True`, it creates cancelled tool results if the parent message contains pending tool_use blocks. This change improves the handling of tool execution interruptions by providing relevant feedback in the message flow.
Changed the type of `tool_result_content` in the `create_message` method from `list[ToolResultBlockParam]` to `list[ContentBlockParam]` to ensure mypy compatability.
…uler

Added functionality for managing scheduled jobs, including creation, listing, and cancellation. Introduced `ScheduledJobService` for handling job operations and integrated it into the FastAPI application. Updated the application to start and shutdown the scheduler during lifespan events. Added necessary models and dependencies for scheduled job data handling.
…eduled_jobs

Eliminated the unused `query` parameter from the `list_scheduled_jobs` function in the router. Cleaned up imports in `scheduler.py` by removing type ignore comments for better clarity. Updated the `list_` method in `ScheduledJobService` to reflect the removal of the `query` parameter.
Added entries for SQLite shared memory and write-ahead logging files to `.gitignore`. Enhanced SQLite connection settings in `engine.py` by enabling WAL mode for concurrent access and setting a busy timeout to prevent database locking issues. Removed unused return type documentation in `executor.py` for clarity.
Refactored the `create` method in `ScheduledJob` to accept `params` of type `ScheduledJobCreate` instead of individual parameters. Updated the `create_scheduled_job` function in the router to pass `params` directly to the service. Cleaned up imports and removed unnecessary data construction in the router for improved clarity.
…e ScheduledJob creation

Introduced a new `name` field in the `MessageRerunnerDataCreate` model to enhance the data structure. Updated the `ScheduledJob` creation process to include the `name` parameter from `params.data`, ensuring that the new field is properly utilized during job creation.
Updated the `execute_job` function to support the new `askui_token` field in `ScheduledJobData`. Implemented environment variable management for `ASKUI_TOKEN` and `AUTHORIZATION` headers to accommodate different authentication methods. Refactored the job execution logic to ensure proper handling of new job types and restore previous environment states after execution. Enhanced the `ScheduledJobCreate` model to include the `askui_token` parameter for authenticated API calls.
…te configuration, get around the write lock when scheduler and Runner wants to write to the same DB

Introduced a new `scheduler_url` field in `DbSettings` for APScheduler job storage, allowing separate database management. Updated the `engine.py` to utilize the new scheduler database and removed unused SQLite connection settings. Enhanced the `scheduler.py` to create a dedicated engine for the scheduler database and ensure proper SQLite configuration for foreign key support. Updated logging to use a private logger for better encapsulation.
…r handling

Refactored the `execute_job` function to utilize a new `_execute_message_rerunner_job` helper function for better clarity and separation of concerns. Updated the handling of `MessageRerunnerData` and improved error messages for better debugging. Removed unused imports and ensured proper type hints throughout the code. Enhanced the `ScheduledJob` model to streamline the extraction of `next_fire_time` and improved the handling of workspace validation in the `ScheduledJobService` class.
…ction for unauthorized issues after token expiry
…35-scheduling-workflows-which-run-on-a-specific-time
Updated the `execute_job` function to improve the handling of `askui_token` by utilizing `SecretStr` for better security. Refactored the logic to manage the `ASKUI__AUTHORIZATION` environment variable, ensuring proper encoding of the token. Enhanced the extraction of `next_fire_time` in the `ScheduledJob` model for clearer error handling. Updated the `ScheduledJobService` to pass the decoded token securely during job execution. This refactor aims to streamline job execution and improve overall code clarity.
…ecutionResult

Modified the `execute_job` function to return a `ScheduledJobExecutionResult`, encapsulating job data and optional error messages. Enhanced error handling during job execution, ensuring that the previous `ASKUI__AUTHORIZATION` environment variable is restored after execution. Improved documentation for the function's parameters and return type to clarify its behavior and expected output.
@danyalxahid-askui danyalxahid-askui marked this pull request as ready for review January 2, 2026 10:53
…database settings

Refactored the `DbSettings` class to consolidate the database URL for SQLAlchemy connections, removing the separate `scheduler_url` field. Updated the database engine configuration in `engine.py` to utilize optimized SQLite pragmas for better performance and concurrency. Adjusted the `scheduler.py` to use the shared engine, ensuring that APScheduler operates with the same database settings. Enhanced the `.gitignore` to include SQLite shared memory and write-ahead logging files for improved project cleanliness.
Updated the `ScheduledJobService` to return a sorted list of scheduled jobs based on their `next_fire_time`. This change enhances the order of job execution, ensuring that jobs are processed in a timely manner.
Copy link
Contributor

@onur-askui onur-askui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that we can use one db now [: 👍

@danyalxahid-askui danyalxahid-askui merged commit 3a010ad into main Jan 7, 2026
1 check passed
@danyalxahid-askui danyalxahid-askui deleted the CL-1935-scheduling-workflows-which-run-on-a-specific-time branch January 7, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants