feat(worker): Configurable worker capabilities and limits per capability #224

Closed
opened 2026-01-24 17:47:25 +00:00 by jack · 0 comments
Owner

Summary

Currently all spawned workers have identical capabilities. Workers should be configurable to have specialized capabilities, with optional limits per capability type.

Current Behavior

All workers are spawned with the same set of capabilities. There's no way to:

  • Create specialized workers (e.g., one worker only for summarize, another only for extract)
  • Limit how many workers can handle a specific capability
  • Prioritize certain capabilities over others

Proposed Features

1. Worker Capability Profiles

Define worker profiles in settings:

{
  "WORKER_PROFILES": {
    "summarizer": {
      "capabilities": ["summarize", "claude-md"],
      "count": 2
    },
    "extractor": {
      "capabilities": ["extract"],
      "count": 1
    },
    "general": {
      "capabilities": ["summarize", "extract", "claude-md", "embed"],
      "count": 1
    }
  }
}

2. Capability Limits

Limit concurrent workers per capability:

{
  "CAPABILITY_LIMITS": {
    "summarize": 3,
    "extract": 2,
    "embed": 1,
    "claude-md": 2
  }
}

This prevents resource exhaustion for expensive operations (e.g., only 1 worker doing embeddings at a time).

3. Alternative: Simple Configuration

For simpler use cases, allow configuring capabilities per worker slot:

{
  "WORKERS": [
    { "capabilities": ["summarize", "claude-md"] },
    { "capabilities": ["summarize", "claude-md"] },
    { "capabilities": ["extract"] },
    { "capabilities": ["embed"] }
  ]
}

Benefits

Feature Benefit
Specialized workers Better resource utilization, predictable performance
Capability limits Prevent API rate limiting, control costs
Profiles Easy scaling of specific workload types

Implementation Considerations

WorkerProcessManager Changes

interface WorkerProfile {
  capabilities: WorkerCapability[];
  count: number;
  priority?: number;
}

// Spawn workers based on profiles
for (const [name, profile] of Object.entries(profiles)) {
  for (let i = 0; i < profile.count; i++) {
    this.spawn({
      capabilities: profile.capabilities,
      profileName: name
    });
  }
}

TaskDispatcher Changes

// Check capability limits before assignment
const currentCount = this.getWorkersWithCapability(capability);
const limit = this.capabilityLimits[capability];

if (limit && currentCount >= limit) {
  // Wait or use fallback capability
}

UI Changes

  • Display worker profiles in Workers tab
  • Show capability distribution
  • Allow editing profiles (optional)

Use Cases

  1. Cost Control: Limit embed workers to 1 to control embedding API costs
  2. Priority Tasks: Dedicate workers to summarize for faster session summaries
  3. Isolation: Separate extract workers to prevent blocking other tasks
  4. Scaling: Easily scale specific capabilities based on workload

Acceptance Criteria

  • Workers can be spawned with specific capability sets
  • Capability limits can be configured in settings
  • UI shows worker capabilities and profiles
  • Default behavior remains backwards-compatible (all capabilities if not configured)
  • Documentation for configuration options
## Summary Currently all spawned workers have identical capabilities. Workers should be configurable to have specialized capabilities, with optional limits per capability type. ## Current Behavior All workers are spawned with the same set of capabilities. There's no way to: - Create specialized workers (e.g., one worker only for `summarize`, another only for `extract`) - Limit how many workers can handle a specific capability - Prioritize certain capabilities over others ## Proposed Features ### 1. Worker Capability Profiles Define worker profiles in settings: ```json { "WORKER_PROFILES": { "summarizer": { "capabilities": ["summarize", "claude-md"], "count": 2 }, "extractor": { "capabilities": ["extract"], "count": 1 }, "general": { "capabilities": ["summarize", "extract", "claude-md", "embed"], "count": 1 } } } ``` ### 2. Capability Limits Limit concurrent workers per capability: ```json { "CAPABILITY_LIMITS": { "summarize": 3, "extract": 2, "embed": 1, "claude-md": 2 } } ``` This prevents resource exhaustion for expensive operations (e.g., only 1 worker doing embeddings at a time). ### 3. Alternative: Simple Configuration For simpler use cases, allow configuring capabilities per worker slot: ```json { "WORKERS": [ { "capabilities": ["summarize", "claude-md"] }, { "capabilities": ["summarize", "claude-md"] }, { "capabilities": ["extract"] }, { "capabilities": ["embed"] } ] } ``` ## Benefits | Feature | Benefit | |---------|---------| | Specialized workers | Better resource utilization, predictable performance | | Capability limits | Prevent API rate limiting, control costs | | Profiles | Easy scaling of specific workload types | ## Implementation Considerations ### WorkerProcessManager Changes ```typescript interface WorkerProfile { capabilities: WorkerCapability[]; count: number; priority?: number; } // Spawn workers based on profiles for (const [name, profile] of Object.entries(profiles)) { for (let i = 0; i < profile.count; i++) { this.spawn({ capabilities: profile.capabilities, profileName: name }); } } ``` ### TaskDispatcher Changes ```typescript // Check capability limits before assignment const currentCount = this.getWorkersWithCapability(capability); const limit = this.capabilityLimits[capability]; if (limit && currentCount >= limit) { // Wait or use fallback capability } ``` ### UI Changes - Display worker profiles in Workers tab - Show capability distribution - Allow editing profiles (optional) ## Use Cases 1. **Cost Control**: Limit `embed` workers to 1 to control embedding API costs 2. **Priority Tasks**: Dedicate workers to `summarize` for faster session summaries 3. **Isolation**: Separate `extract` workers to prevent blocking other tasks 4. **Scaling**: Easily scale specific capabilities based on workload ## Acceptance Criteria - [ ] Workers can be spawned with specific capability sets - [ ] Capability limits can be configured in settings - [ ] UI shows worker capabilities and profiles - [ ] Default behavior remains backwards-compatible (all capabilities if not configured) - [ ] Documentation for configuration options
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
customable/claude-mem#224
No description provided.