Repository navigation
Closed
Labels
complexity-mediumComplexity: medium (board points 5-8)
Description
Problem
Multiple objects can get stuck in intermediate states with no automatic recovery:
Stuck Execution Records
create_task_execution()setsstatus="running"- If backend or agent crashes before
update_execution_status(), record stays"running"forever - Tasks tab shows perpetually "running" execution
- No TTL, no cleanup job, no automatic recovery exists
Stuck Activity Records
track_activity()creates activity withactivity_state="started"- If exception occurs before
complete_activity(), activity stays"started"forever - Dashboard timeline shows perpetual spinner
- Code comment at
chat.py:355confirms this was a known bug (fixed for collaboration activities, but may exist in other paths)
Leaked Redis Slots
- SlotService uses Redis ZSET (
agent:slots:{name}) to track active execution slots - ZSET entries have no auto-expire — only metadata hashes expire (1800s)
- Stale cleanup only runs when next
acquire_slot()is called - If no new tasks arrive after a crash, slots stay reserved indefinitely
- Agent appears "at capacity" permanently
Leaked Redis Queue
- Execution queue key
agent:running:{name}has 600s TTL (auto-cleans) - But queue list
agent:queue:{name}has no TTL - If items get orphaned in the queue list, they stay forever
Required Changes
1. Background Cleanup Job (runs every 5 minutes)
async def cleanup_stale_records():
# Executions stuck in "running" for >30 minutes → mark "failed"
# Activities stuck in "started" for >30 minutes → mark "failed"
# Redis slots older than SLOT_TTL → remove from ZSET
# Redis queue items without matching running key → clear2. Startup Cleanup
On backend startup, sweep for any records stuck from a previous crash.
3. Health Check Integration
Add stuck-record counts to the health/monitoring endpoint so operators can see problems.
Files to Change
src/backend/services/cleanup_service.py— NEW: periodic cleanupsrc/backend/main.py— Register cleanup on startupsrc/backend/db/schedules.py— Query for stuck executionssrc/backend/db/activities.py— Query for stuck activitiessrc/backend/services/slot_service.py— Add periodic ZSET cleanupsrc/backend/services/execution_queue.py— Add queue orphan cleanup
Metadata
Metadata
Assignees
Labels
complexity-mediumComplexity: medium (board points 5-8)
Activity
refactor: Standardize execution status values and add cleanup service
vybe commentedon Mar 30, 2026
Actualization (2026-03-30)
All items in this issue are fully implemented in
src/backend/services/cleanup_service.py(271 lines):Implemented:
failedactivity_state='failed'GET /api/monitoring/cleanup-statusPOST /api/monitoring/cleanup-triggerRecent fixes:
This issue can be closed.
vybe commentedon Mar 30, 2026
Closing — fully implemented in cleanup_service.py. See actualization comment above.
feat(grid): widget chassis — InfoTile, GRID_WIDGETS registry, layout …
feat(grid): widget chassis — InfoTile, GRID_WIDGETS registry, layout …
fix(grid): the fleet tile linked to a route that does not exist (ent#…
fix(analytics): give room turns their own bucket; keep them out of th…
rgsaura commentedon Nov 20, 2026
Owner decision (Option B, 2026-11-20): keep the warmed shared sending domain but replace the confusing
<slug>@relay.exohuman.ccsender with a professional transactional identity — instance email is used only for password resets and sign-in codes.Scope agreed:
[email protected](single professional identity; no DNS change required — SPF/DKIM forrelay.exohuman.ccare already aligned and warmed).in-<slug>.mail.exohuman.cc) remains the documented future path; the ops lane established it requires source + DNS + DKIM work under the self-hosted MTA (it was only ever implemented for the retired Resend provider).#94 stays open until the new identity is live on production and verified (one authorized probe).