Skip to content

Unify ExecutionQueue and SlotService (mutual blindness) #98

Description

@vybe

Problem

Two independent concurrency control systems exist that are completely unaware of each other:

System A: Execution Queue (for /api/chat)

  • File: services/execution_queue.py
  • Serial execution (1 at a time per agent)
  • Redis keys: agent:running:{name}, agent:queue:{name}
  • Max 3 queued requests
  • 600s TTL

System B: Slot Service (for /api/task, scheduler, public, paid)

  • File: services/slot_service.py
  • Parallel execution (1-10 concurrent per agent)
  • Redis keys: agent:slots:{name}, agent:slot:{name}:{exec_id}
  • 1800s TTL

Impact

  • A /chat execution occupies the queue but NOT a slot → capacity meter doesn't show it
  • A /task execution occupies a slot but NOT the queue → queue doesn't know about it
  • An agent could have 1 chat + 10 tasks running simultaneously (11 total) while capacity shows 10/10
  • No single system gives a true picture of agent load

Required Changes

Option A (Recommended): SlotService becomes the single source of truth

  1. /api/chat acquires a slot in addition to using the queue
  2. Capacity meter shows ALL execution types
  3. Queue continues to enforce serial chat, but slot tracks the resource usage
  4. Total capacity = max_parallel_tasks (shared between chat and tasks)

Option B: Merge into one system

  1. Replace both with a unified ExecutionManager
  2. Supports both serial (chat) and parallel (task) modes per agent
  3. Single Redis key namespace
  4. Single capacity counter

Files to Change

  • src/backend/services/execution_queue.py — Integrate with SlotService
  • src/backend/services/slot_service.py — Accept queue-based executions
  • src/backend/routers/chat.py — Acquire slot alongside queue
  • src/frontend/src/components/CapacityMeter.vue — May need to show queue vs task breakdown

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions