{"record":{"id":"010ae920dc908430","repo":"tinyhumansai/openhuman","slug":"unknown-dependency-depends-on","errorCode":null,"errorMessage":"unknown dependency: {depends_on}","messagePattern":"unknown dependency: (.+?)","errorType":"validation","errorClass":"TeamError","httpStatus":null,"severity":"error","filePath":"src/openhuman/agent/orchestration/agent_teams/ops.rs","lineNumber":409,"sourceCode":"/// Rejects self-dependency, unknown dependency ids, and any edge that would\n/// introduce a cycle. The cycle check builds the full graph (existing tasks +\n/// the new task with its proposed deps) and runs Kahn's algorithm — the same\n/// shape used for workflow phase graphs in `workflow_runs::ops::has_cycle`.\nfn validate_dependencies(\n    new_task_id: &str,\n    depends_on: &[String],\n    existing: &[AgentTeamTask],\n) -> Result<()> {\n    let known: HashSet<&str> = existing.iter().map(|t| t.id.as_str()).collect();\n\n    for dep in depends_on {\n        if dep == new_task_id {\n            return Err(anyhow!(TeamError::SelfDependency {\n                task_id: new_task_id.to_string(),\n            }));\n        }\n        if !known.contains(dep.as_str()) {\n            return Err(anyhow!(TeamError::UnknownDependency {\n                depends_on: dep.clone(),\n            }));\n        }\n    }\n\n    if has_task_cycle(new_task_id, depends_on, existing) {\n        return Err(anyhow!(TeamError::CyclicDependency));\n    }\n\n    Ok(())\n}\n\n/// Kahn's-algorithm cycle check over the task dependency graph (existing tasks\n/// plus the candidate new task). Edge `dep -> task` means `task` depends on\n/// `dep`. Edges pointing at unknown ids are ignored here (rejected separately).\nfn has_task_cycle(\n    new_task_id: &str,\n    new_depends_on: &[String],","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/src/openhuman/agent/orchestration/agent_teams/ops.rs#L391-L427","documentation":"Thrown by agent_teams::ops::validate_dependencies (via assign_task) when a depends_on entry does not match the id of any existing task in the team. Dependencies must reference tasks already created in the same team; unknown ids abort the assignment before the ledger write. It wraps TeamError::UnknownDependency, carrying the offending dep id.","triggerScenarios":"Calling assign_task with a dep id that is not in the team's existing task list — dependency task not yet created, created in a different team, a typo, or the dep task's creation failed earlier in a batch.","commonSituations":"Batch task creation that does not wait for each assign_task to persist before referencing the next; refactoring that moved tasks between teams; trailing whitespace or case differences in dep ids.","solutions":["Create dependency tasks first and await each success before tasks that reference them","Cross-check depends_on against the team's task list (agent_teams get) before submitting","Trim/normalize ids and verify they belong to the same team_id"],"exampleFix":"// before\nagent_teams::ops::assign_task(&config, &team_id, &new_id, member, &[\"reseach-1\".into()])?; // typo\n\n// after — validate deps against the live task list\nlet tasks = run_ledger::list_agent_team_tasks(&config.workspace_dir, team_id)?;\nlet known: HashSet<&str> = tasks.iter().map(|t| t.id.as_str()).collect();\nlet deps: Vec<String> = depends_on.into_iter().filter(|d| known.contains(d.as_str())).collect();\nagent_teams::ops::assign_task(&config, &team_id, &new_id, member, &deps)?;","handlingStrategy":"validation","validationCode":"let tasks = run_ledger::list_agent_team_tasks(&config.workspace_dir, team_id)?;\nlet known: HashSet<&str> = tasks.iter().map(|t| t.id.as_str()).collect();\nanyhow::ensure!(depends_on.iter().all(|d| known.contains(d.as_str())), \"unknown dependency\");","typeGuard":"fn deps_are_known(existing: &[AgentTeamTask], depends_on: &[String]) -> bool {\n    let known: HashSet<&str> = existing.iter().map(|t| t.id.as_str()).collect();\n    depends_on.iter().all(|d| known.contains(d.as_str()))\n}","tryCatchPattern":null,"preventionTips":["Create tasks in topological order and await each assign_task success before dependent tasks","Build dependency lists from ids returned by prior assign_task calls, never hand-typed","If a batch partially fails, reconcile the created set before continuing the batch"],"tags":["agent-teams","tasks","dependencies","validation"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}