tinyhumansai/openhuman · error · TeamError

dependency cycle detected

Error message

dependency cycle detected

What it means

has_task_cycle (Kahn's algorithm over existing tasks plus the new one) detected that the proposed dependency edges would introduce a cycle (TeamError::DependencyCycle). The new task's deps, combined with existing edges, form a strongly connected wait graph; the scheduler would deadlock, so the assignment is rejected before any state changes.

Solutions

  1. Trace the cycle reported in the error and remove or reverse the edge that closes it
  2. Restructure the dependent tasks into sequential phases so the wait graph is a DAG
  3. Re-run task assignment after breaking the cycle
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/openhuman/agent/orchestration/agent_teams/ops.rs:416 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/240bdb16da62a322. Report an issue: GitHub.

Appendix: source

Thrown at src/openhuman/agent/orchestration/agent_teams/ops.rs:416

    existing: &[AgentTeamTask],
) -> Result<()> {
    let known: HashSet<&str> = existing.iter().map(|t| t.id.as_str()).collect();

    for dep in depends_on {
        if dep == new_task_id {
            return Err(anyhow!(TeamError::SelfDependency {
                task_id: new_task_id.to_string(),
            }));
        }
        if !known.contains(dep.as_str()) {
            return Err(anyhow!(TeamError::UnknownDependency {
                depends_on: dep.clone(),
            }));
        }
    }

    if has_task_cycle(new_task_id, depends_on, existing) {
        return Err(anyhow!(TeamError::CyclicDependency));
    }

    Ok(())
}

/// Kahn's-algorithm cycle check over the task dependency graph (existing tasks
/// plus the candidate new task). Edge `dep -> task` means `task` depends on
/// `dep`. Edges pointing at unknown ids are ignored here (rejected separately).
fn has_task_cycle(
    new_task_id: &str,
    new_depends_on: &[String],
    existing: &[AgentTeamTask],
) -> bool {
    // Node set: every existing task id plus the new one.
    let mut nodes: HashSet<&str> = existing.iter().map(|t| t.id.as_str()).collect();
    nodes.insert(new_task_id);

    let mut indegree: HashMap<&str, usize> = nodes.iter().map(|&n| (n, 0)).collect();

View on GitHub (pinned to 7491200858)