Skip to content

fix: Show scheduled tasks in sidebar after container restart#1004

Open
moortekweb-art wants to merge 1 commit intoagent0ai:mainfrom
moortekweb-art:fix/scheduled-tasks-visibility
Open

fix: Show scheduled tasks in sidebar after container restart#1004
moortekweb-art wants to merge 1 commit intoagent0ai:mainfrom
moortekweb-art:fix/scheduled-tasks-visibility

Conversation

@moortekweb-art
Copy link

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.py endpoint only returns tasks that have an active AgentContext in memory (AgentContext._contexts). When the container restarts, all AgentContext objects are lost, but tasks persist in the scheduler's JSON file.

Solution

Extend poll.py to also include tasks from TaskScheduler.serialize_all_tasks() that don't have active contexts. This ensures scheduled tasks remain visible in the UI after restarts.

Changes

  • Added datetime import
  • Added processed_task_uuids set to track which tasks have been processed
  • Added loop to include tasks from scheduler that don't have active AgentContexts
  • Creates minimal context-like data structure for orphaned tasks

Testing

  1. Create a scheduled task
  2. Restart the container: docker restart agent-zero
  3. Open the UI - task should still be visible in the sidebar

Impact

  • No breaking changes
  • Backward compatible
  • Minimal performance impact (just reads existing scheduler data)

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
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.

1 participant

Comments