Skip to content

[Phase 4] Per-State Concurrency Limits for Batch Execution #407

Description

@frankbria

Summary

Add per-state concurrency limits to batch execution, allowing different parallelism levels for tasks in different states. Inspired by Symphony's max_concurrent_agents_by_state configuration.

Motivation

Currently cf work batch run --max-parallel N applies a single global concurrency limit. In practice, teams may want different limits based on task state or type — for example, allowing more agents on READY tasks but limiting how many IN_PROGRESS tasks run simultaneously to avoid resource contention.

This becomes more important in Phase 4 multi-agent scenarios where different agent roles may have different resource requirements.

Design (single session)

Changes to core/conductor.py

  1. Add ConcurrencyConfig dataclass:

    @dataclass
    class ConcurrencyConfig:
        max_parallel: int = 4              # global limit
        by_status: dict[str, int] = {}     # per-status limits
        # e.g., {"READY": 3, "IN_PROGRESS": 2, "BLOCKED": 1}
  2. Update _get_available_slots() to check both global and per-status limits:

    • Global slots = max_parallel - running_count
    • Per-status slots = by_status[status] - running_count_for_status
    • Available = min(global_slots, per_status_slots)
  3. Update dispatch logic to count running tasks by status

Changes to cli/app.py

  1. Add --max-parallel-by-status flag:
    cf work batch run --all-ready --max-parallel 4 --max-parallel-by-status "READY=3,IN_PROGRESS=2"

Changes to config

  1. Support in AGENTS.md/CODEFRAME.md:
    batch:
      max_parallel: 4
      max_parallel_by_status:
        READY: 3
        IN_PROGRESS: 2

Acceptance Criteria

  • Per-status limits respected during parallel batch execution
  • Global limit still enforced as upper bound
  • --max-parallel-by-status CLI flag works
  • Config file loading works
  • Status counts updated correctly as tasks transition
  • Unspecified statuses fall back to global limit
  • Unit tests for slot calculation with mixed status limits
  • Integration test: batch with per-status limits

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestphase-4.4Phase 4.4: Batch Execution & Reconciliationsymphony-inspiredInspired by OpenAI Symphony spec analysis

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions