Agent Workflow Dependencies
You're building an AI agent orchestration system. Agents have dependencies — an agent cannot run until all its dependencies complete.
Part 1: get_execution_order(agents, dependencies) — Return a valid execution order using topological sort. Return None if there's a cycle.
Part 2: find_critical_path(agents, durations, dependencies) — Return the minimum total time to complete all agents (longest path in the DAG).
Example:
agents = ["data_fetch", "preprocess", "model_run", "postprocess"]
dependencies = [
("data_fetch", "preprocess"),
("preprocess", "model_run"),
("model_run", "postprocess"),
]
get_execution_order(...) → ["data_fetch", "preprocess", "model_run", "postprocess"]
Hints
solution.py
Python ready
Test Output
▶
Click "Run Tests" to execute your code