fix: Show scheduled tasks in sidebar after container restart#1004
Open
moortekweb-art wants to merge 1 commit intoagent0ai:mainfrom
Open
fix: Show scheduled tasks in sidebar after container restart#1004moortekweb-art wants to merge 1 commit intoagent0ai:mainfrom
moortekweb-art wants to merge 1 commit intoagent0ai:mainfrom
Conversation
After a container restart, scheduled tasks would disappear from the sidebar UI even though they still exist in tmp/scheduler/tasks.json. The poll endpoint only returned tasks with active AgentContext objects in memory. When the container restarts, all AgentContext objects are lost, but tasks persist in the scheduler's JSON file. This fix extends poll.py to also include tasks from the scheduler that don't have active contexts, ensuring scheduled tasks remain visible in the UI after restarts. Tested by: 1. Creating scheduled tasks 2. Restarting container with `docker restart agent-zero` 3. Verifying tasks still appear in sidebar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After a container restart, scheduled tasks disappear from the sidebar UI even though they still exist in
tmp/scheduler/tasks.json. Users must manually trigger each task to make them visible again.Root Cause
The
poll.pyendpoint only returns tasks that have an activeAgentContextin memory (AgentContext._contexts). When the container restarts, allAgentContextobjects are lost, but tasks persist in the scheduler's JSON file.Solution
Extend
poll.pyto also include tasks fromTaskScheduler.serialize_all_tasks()that don't have active contexts. This ensures scheduled tasks remain visible in the UI after restarts.Changes
datetimeimportprocessed_task_uuidsset to track which tasks have been processedTesting
docker restart agent-zeroImpact