mirror of
https://github.com/RightNow-AI/openfang.git
synced 2026-07-30 23:05:08 +00:00
Bug: in activate_hand(), kill_agent() is called on the existing agent BEFORE the new agent is spawned. kill_agent() invokes cron_scheduler.remove_agent_jobs() which deletes all cron jobs from memory AND persists [] to cron_jobs.json. The reassign_agent_jobs() call further down was meant to migrate jobs from old to new (per #461), but it always runs as a no-op because the jobs are already gone — the order of operations defeats the fix. Symptom: every daemon restart silently destroys cron jobs for hand-style agents. cron_jobs.json is rewritten as []. /api/cron/jobs returns empty. No error message. Fix: snapshot the cron jobs into a local Vec BEFORE kill_agent (same pattern as saved_triggers above), then re-add them under the new agent_id AFTER spawn_agent_with_parent. Runtime state (next_run, last_run) is reset so jobs get a fresh start. The existing reassign_agent_jobs() block is kept as a defensive safety net but is now redundant in the common path. Verified with cargo check -p openfang-kernel --lib (clean compile, no warnings). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>