How do you structure an agent plan to ensure code modularity and reliability?
Implement build_agent_plan(plan) to validate and order independent agent steps. Each step must have a unique non-empty id, a non-empty action, a depends_on list, an integer retries from 0 to 3, and an idempotent boolean. A step with retries greater than zero must be idempotent. Return step IDs in a valid deterministic execution order, preserving input order when multiple steps are available. Return None for invalid plans, including missing dependencies or dependency cycles.
Input is a list of step dictionaries. Output is a list of strings or None.
def build_agent_plan(plan):