An architect is building an agent that uses a 'Plan-and-Execute' pattern. The agent first generates a multi-step plan, then executes each step. During execution, the agent discovers that Step 2 is impossible due to a missing API key. How should the agent be designed to handle this?
This is the 'Re-planner' pattern. When a failure occurs, the agent should take the error information and feed it back into the planning model. This allows the model to generate an alternative strategy that achieves the goal without the missing API key, or to inform the user about the specific requirement needed.
Why this answer
Dynamic re-planning is a key feature of advanced agentic systems. When an agent encounters an obstacle that prevents the execution of a pre-defined plan, it must be able to recognize the failure, update its internal state, and generate a new plan that either bypasses the problem or addresses the root cause, rather than continuing to attempt a doomed plan.
Exam trap
Candidates often assume the agent should just retry the failed step or throw an error, failing to realize the agent must re-plan based on the new environmental constraint.