Skip to content

[P1] Implement LeadAgent.detect_bottlenecks() logic #101

Description

@frankbria

Overview

Bottleneck detection is critical for optimizing multi-agent workflows, but the method is currently stubbed.

Current State

File: codeframe/agents/lead_agent.py lines 594-596

def detect_bottlenecks(self) -> list:
    """Detect workflow bottlenecks."""
    # TODO: Implement bottleneck detection
    return []

Expected Behavior

Detect bottlenecks when:

  • Tasks are waiting on dependencies longer than threshold
  • Agents are idle while tasks are blocked
  • Specific agents are overloaded with too many assignments
  • Critical path tasks are delayed

Implementation Requirements

  1. Query database for tasks with status='blocked' or 'waiting'
  2. Calculate wait times for each blocked task
  3. Identify agents with excessive workload (>5 tasks)
  4. Identify idle agents (0 tasks assigned)
  5. Detect dependency chain delays
  6. Return list of bottleneck descriptors with severity

Return Format

[
    {
        "type": "dependency_wait",
        "task_id": 27,
        "wait_time_minutes": 120,
        "blocking_task_id": 25,
        "severity": "high"
    },
    {
        "type": "agent_overload",
        "agent_id": "backend-001",
        "assigned_tasks": 8,
        "severity": "medium"
    }
]

Acceptance Criteria

  • Bottlenecks detected for dependency waits
  • Bottlenecks detected for agent overload/underload
  • Severity levels assigned correctly
  • Recommendations provided for resolution
  • Unit tests verify detection logic
  • Integration tests verify bottleneck reporting

Priority

P1 - Critical: Required for efficient multi-agent coordination and preventing workflow stalls.

References

  • User Documentation: CODEFRAME_USER_DOCUMENTATION.md lines 277-278
  • Issues Analysis: CODEFRAME_ISSUES_ANALYSIS.md lines 31-38

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions